2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								/*
  
						 
					
						
							
								
									
										
										
										
											2022-03-26 14:21:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2018 - 2022 ,  Andreas  Kling  < kling @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-28 22:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2020 - 2021 ,  the  SerenityOS  developers . 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-06 17:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2021 - 2023 ,  Sam  Atkins  < atkinssj @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 21:28:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2021 ,  Tobias  Christiansen  < tobyase @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-12 00:15:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  Copyright  ( c )  2022 ,  MacDue  < macdue @ dueutil . tech > 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-22 01:24:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-24 21:22:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <AK/CharacterTypes.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-07-23 13:06:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <AK/Debug.h> 
  
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <AK/GenericLexer.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:20:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <AK/SourceLocation.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <AK/TemporaryChange.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSFontFaceRule.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-09-30 22:57:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSImportRule.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:30:54 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSKeyframeRule.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSKeyframesRule.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-09-29 15:51:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSMediaRule.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-07-29 11:51:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSNamespaceRule.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-07-09 16:34:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSStyleDeclaration.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSStyleRule.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSStyleSheet.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-10-08 17:48:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CSSSupportsRule.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:33:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/CalculatedOr.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-30 14:22:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/EdgeRect.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-10-23 21:05:34 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/MediaList.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-04-12 14:08:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/Parser/Block.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/Parser/ComponentValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/Parser/DeclarationOrAtRule.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-04-12 13:35:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/Parser/Function.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/Parser/Parser.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/Parser/Rule.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/Selector.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-23 17:26:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/AngleStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-23 17:44:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-23 17:54:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-25 00:33:20 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-23 21:12:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/ColorStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-23 21:17:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/ContentStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-05-25 12:43:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/DisplayStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-07-06 02:29:36 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/EasingStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/EdgeStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-23 21:26:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-09-28 15:18:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/FlexStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-23 21:50:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/FrequencyStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-08-17 20:25:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/GridAutoFlowStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 14:25:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 14:53:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-29 17:59:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 15:04:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/IdentifierStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 15:17:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/ImageStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 16:45:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/InheritStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 16:55:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/InitialStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/IntegerStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 17:04:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/LengthStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-09-07 15:29:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/MathDepthStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-06-01 16:16:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/NumberStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 17:28:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/PercentageStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 17:35:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/PositionStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-06-06 15:42:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/RatioStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-25 00:02:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/RectStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 17:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/ResolutionStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-07-29 17:14:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/RevertStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 17:45:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/ShadowStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-09-19 12:21:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/ShorthandStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 17:48:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/StringStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-25 00:12:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/StyleValueList.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 23:47:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/TimeStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 17:59:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/TransformationStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-04-21 18:31:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/URLStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 23:53:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/UnresolvedStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-03-24 23:56:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/CSS/StyleValues/UnsetStyleValue.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-04-29 21:16:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Dump.h> 
  
						 
					
						
							
								
									
										
										
										
											2023-02-17 15:21:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								# include  <LibWeb/Infra/Strings.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:58:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  void  log_parse_error ( SourceLocation  const &  location  =  SourceLocation : : current ( ) )  
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:20:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-07-23 13:06:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    dbgln_if ( CSS_PARSER_DEBUG ,  " Parse error (CSS) {} " ,  location ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:20:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 12:00:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								namespace  Web : : CSS : : Parser  {  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-06 17:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								ErrorOr < Parser >  Parser : : create ( ParsingContext  const &  context ,  StringView  input ,  StringView  encoding )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TRY ( Tokenizer : : tokenize ( input ,  encoding ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  Parser  {  context ,  move ( tokens )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Parser : : Parser ( ParsingContext  const &  context ,  Vector < Token >  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 14:00:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    :  m_context ( context ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-06 17:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_tokens ( move ( tokens ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_token_stream ( m_tokens ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Parser : : Parser ( Parser & &  other )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    :  m_context ( other . m_context ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_tokens ( move ( other . m_tokens ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    ,  m_token_stream ( m_tokens ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 14:00:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-03-06 17:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Moving the TokenStream directly from `other` would break it, because TokenStream holds
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // a reference to the Vector<Token>, so it would be pointing at the old Parser's tokens.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // So instead, we create a new TokenStream from this Parser's tokens, and then tell it to
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // copy the other TokenStream's state. This is quite hacky.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    m_token_stream . copy_state ( { } ,  other . m_token_stream ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 14:00:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:51:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.3.3. Parse a stylesheet
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-stylesheet
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-03-29 14:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Parser : : ParsedStyleSheet  Parser : : parse_a_stylesheet ( TokenStream < T > &  tokens ,  Optional < AK : : URL >  location )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:51:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a stylesheet from an input given an optional url location:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If input is a byte stream for stylesheet, decode bytes from input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: These are done automatically when creating the Parser.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Create a new stylesheet, with its location set to location (or null, if location was not passed).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 14:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ParsedStyleSheet  style_sheet ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    style_sheet . location  =  move ( location ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:51:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 4. Consume a list of rules from input, with the top-level flag set, and set the stylesheet’  
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 14:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    style_sheet . rules  =  consume_a_list_of_rules ( tokens ,  TopLevel : : Yes ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 14:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. Return the stylesheet.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  style_sheet ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-a-css-stylesheet
  
						 
					
						
							
								
									
										
										
										
											2022-08-07 13:14:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSStyleSheet *  Parser : : parse_as_css_stylesheet ( Optional < AK : : URL >  location )  
						 
					
						
							
								
									
										
										
										
											2022-03-29 14:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a CSS stylesheet, first parse a stylesheet.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  style_sheet  =  parse_a_stylesheet ( m_token_stream ,  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Interpret all of the resulting top-level qualified rules as style rules, defined below.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 16:34:04 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    JS : : MarkedVector < CSSRule * >  rules ( m_context . realm ( ) . heap ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 14:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  raw_rule  :  style_sheet . rules )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 15:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto *  rule  =  convert_to_rule ( raw_rule ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 14:13:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								        // If any style rule is invalid, or any at-rule is not recognized or is invalid according to its grammar or context, it’  
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 12:34:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( rule ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 15:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            rules . append ( rule ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 12:34:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  rule_list  =  CSSRuleList : : create ( m_context . realm ( ) ,  rules ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  media_list  =  MediaList : : create ( m_context . realm ( ) ,  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  CSSStyleSheet : : create ( m_context . realm ( ) ,  rule_list ,  media_list ,  move ( location ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 12:34:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < Supports >  Parser : : parse_as_supports ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  parse_a_supports ( m_token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < Supports >  Parser : : parse_a_supports ( TokenStream < T > &  tokens )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  component_values  =  parse_a_list_of_component_values ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream < ComponentValue >  token_stream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_condition  =  parse_supports_condition ( token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    token_stream . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( maybe_condition  & &  ! token_stream . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  Supports : : create ( maybe_condition . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								OwnPtr < Supports : : Condition >  Parser : : parse_supports_condition ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  peeked_token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // `not <supports-in-parens>`
 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( peeked_token . is ( Token : : Type : : Ident )  & &  peeked_token . token ( ) . ident ( ) . equals_ignoring_ascii_case ( " not " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  child  =  parse_supports_in_parens ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! child . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  condition  =  make < Supports : : Condition > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        condition - > type  =  Supports : : Condition : : Type : : Not ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        condition - > children . append ( child . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  condition ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // `  <supports-in-parens> [ and <supports-in-parens> ]*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  | <supports-in-parens> [ or <supports-in-parens> ]*`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < Supports : : InParens >  children ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < Supports : : Condition : : Type >  condition_type  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  as_condition_type  =  [ ] ( auto &  token )  - >  Optional < Supports : : Condition : : Type >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! token . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  token . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " and " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Supports : : Condition : : Type : : And ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " or " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Supports : : Condition : : Type : : Or ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! children . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Expect `and` or `or` here
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_combination  =  as_condition_type ( tokens . next_token ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_combination . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! condition_type . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                condition_type  =  maybe_combination . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( maybe_combination  ! =  condition_type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  in_parens  =  parse_supports_in_parens ( tokens ) ;  in_parens . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            children . append ( in_parens . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( children . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  condition  =  make < Supports : : Condition > ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    condition - > type  =  condition_type . value_or ( Supports : : Condition : : Type : : Or ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    condition - > children  =  move ( children ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  condition ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Supports : : InParens >  Parser : : parse_supports_in_parens ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // `( <supports-condition> )`
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  first_token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( first_token . is_block ( )  & &  first_token . block ( ) . is_paren ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        TokenStream  child_tokens  {  first_token . block ( ) . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  condition  =  parse_supports_condition ( child_tokens ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( child_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Supports : : InParens  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                . value  =  {  condition . release_nonnull ( )  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // `<supports-feature>`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  feature  =  parse_supports_feature ( tokens ) ;  feature . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  Supports : : InParens  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            . value  =  {  feature . release_value ( )  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // `<general-enclosed>`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  general_enclosed  =  parse_general_enclosed ( tokens ) ;  general_enclosed . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  Supports : : InParens  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-24 14:20:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            . value  =  general_enclosed . release_value ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Supports : : Feature >  Parser : : parse_supports_feature ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  first_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // `<supports-decl>`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( first_token . is_block ( )  & &  first_token . block ( ) . is_paren ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        TokenStream  block_tokens  {  first_token . block ( ) . values ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 17:22:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Parsing and then converting back to a string is weird.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  declaration  =  consume_a_declaration ( block_tokens ) ;  declaration . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Supports : : Feature  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 13:00:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                Supports : : Declaration  {  declaration - > to_string ( ) ,  JS : : make_handle ( m_context . realm ( ) )  } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 17:22:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // `<supports-selector-fn>`
 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( first_token . is_function ( )  & &  first_token . function ( ) . name ( ) . equals_ignoring_ascii_case ( " selector " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 17:22:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Parsing and then converting back to a string is weird.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        StringBuilder  builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  const &  item  :  first_token . function ( ) . values ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 13:00:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            builder . append ( item . to_string ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 17:22:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  Supports : : Feature  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-28 16:54:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Supports : : Selector  {  builder . to_string ( ) . release_value_but_fixme_should_propagate_errors ( ) ,  JS : : make_handle ( m_context . realm ( ) )  } 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 17:22:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 17:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/mediaqueries-4/#typedef-general-enclosed
  
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < GeneralEnclosed >  Parser : : parse_general_enclosed ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 17:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  first_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 17:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-29 12:27:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // `[ <function-token> <any-value>? ) ]`
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( first_token . is_function ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 13:00:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  GeneralEnclosed  {  first_token . to_string ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 17:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-29 12:27:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // `( <any-value>? )`
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( first_token . is_block ( )  & &  first_token . block ( ) . is_paren ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 13:00:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  GeneralEnclosed  {  first_token . to_string ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 16:33:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-22 17:27:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.4.1. Consume a list of rules
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-list-of-rules
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2023-03-06 14:17:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector < NonnullRefPtr < Rule > >  Parser : : consume_a_list_of_rules ( TokenStream < T > &  tokens ,  TopLevel  top_level )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To consume a list of rules, given a top-level flag:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Create an initially empty list of rules.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-06 14:17:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < NonnullRefPtr < Rule > >  rules ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Repeatedly consume the next input token:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <whitespace-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Whitespace ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Do nothing.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <EOF-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Return the list of rules.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  rules ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <CDO-token>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <CDC-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : CDO )  | |  token . is ( Token : : Type : : CDC ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // If the top-level flag is set, do nothing.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( top_level  = =  TopLevel : : Yes ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, reconsume the current input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume a qualified rule. If anything is returned, append it to the list of rules.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  maybe_qualified  =  consume_a_qualified_rule ( tokens ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-01 16:49:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                rules . append ( maybe_qualified . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <at-keyword-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : AtKeyword ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume an at-rule, and append the returned value to the list of rules.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            rules . append ( consume_an_at_rule ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:03:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // anything else
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume a qualified rule. If anything is returned, append it to the list of rules.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  maybe_qualified  =  consume_a_qualified_rule ( tokens ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                rules . append ( maybe_qualified . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.4.2. Consume an at-rule
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-at-rule
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								NonnullRefPtr < Rule >  Parser : : consume_an_at_rule ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To consume an at-rule:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Consume the next input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  name_ident  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( name_ident . is ( Token : : Type : : AtKeyword ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Create a new at-rule with its name set to the value of the current input token, its prelude initially set to an empty list, and its value initially set to nothing.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: We create the Rule fully initialized when we return it instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-15 11:28:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  at_rule_name  =  FlyString : : from_utf8 ( ( ( Token ) name_ident ) . at_keyword ( ) ) . release_value_but_fixme_should_propagate_errors ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 17:03:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  prelude ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < Block >  block ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Repeatedly consume the next input token:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <semicolon-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Semicolon ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Return the at-rule.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Rule : : make_at_rule ( move ( at_rule_name ) ,  move ( prelude ) ,  move ( block ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <EOF-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // This is a parse error. Return the at-rule.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:20:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Rule : : make_at_rule ( move ( at_rule_name ) ,  move ( prelude ) ,  move ( block ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <{-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : OpenCurly ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								            // Consume a simple block and assign it to the at-rule’  
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 17:03:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            block  =  consume_a_simple_block ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Rule : : make_at_rule ( move ( at_rule_name ) ,  move ( prelude ) ,  move ( block ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // simple block with an associated token of <{-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  constexpr  ( IsSame < T ,  ComponentValue > )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            ComponentValue  const &  component_value  =  token ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 16:32:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . is_block ( )  & &  component_value . block ( ) . is_curly ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								                // Assign the block to the at-rule’  
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 17:03:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                block  =  component_value . block ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  Rule : : make_at_rule ( move ( at_rule_name ) ,  move ( prelude ) ,  move ( block ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 16:32:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // anything else
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Consume a component value. Append the returned value to the at-rule’  
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 17:03:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            prelude . append ( consume_a_component_value ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:46:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.4.3. Consume a qualified rule
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-qualified-rule
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < Rule >  Parser : : consume_a_qualified_rule ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To consume a qualified rule:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Create a new qualified rule with its prelude initially set to an empty list, and its value initially set to nothing.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: We create the Rule fully initialized when we return it instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 17:03:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  prelude ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < Block >  block ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Repeatedly consume the next input token:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <EOF-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // This is a parse error. Return nothing.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:20:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <{-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : OpenCurly ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								            // Consume a simple block and assign it to the qualified rule’  
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 17:03:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            block  =  consume_a_simple_block ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Rule : : make_qualified_rule ( move ( prelude ) ,  move ( block ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // simple block with an associated token of <{-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  constexpr  ( IsSame < T ,  ComponentValue > )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            ComponentValue  const &  component_value  =  token ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 15:43:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . is_block ( )  & &  component_value . block ( ) . is_curly ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								                // Assign the block to the qualified rule’  
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 17:03:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                block  =  component_value . block ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  Rule : : make_qualified_rule ( move ( prelude ) ,  move ( block ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 15:43:47 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // anything else
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Consume a component value. Append the returned value to the qualified rule’  
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 17:03:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            prelude . append ( consume_a_component_value ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 13:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 16:44:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								// 5.4.4. Consume a style block’   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-a-style-blocks-contents
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Vector < DeclarationOrAtRule >  Parser : : consume_a_style_blocks_contents ( TokenStream < T > &  tokens )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // To consume a style block’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Create an initially empty list of declarations decls, and an initially empty list of rules rules.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < DeclarationOrAtRule >  declarations ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < DeclarationOrAtRule >  rules ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Repeatedly consume the next input token:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <whitespace-token>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <semicolon-token>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Whitespace )  | |  token . is ( Token : : Type : : Semicolon ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Do nothing.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <EOF-token>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Extend decls with rules, then return decls.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            declarations . extend ( move ( rules ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  declarations ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <at-keyword-token>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : AtKeyword ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume an at-rule, and append the result to rules.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            rules . empend ( consume_an_at_rule ( tokens ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <ident-token>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Initialize a temporary list initially filled with the current input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < ComponentValue >  temporary_list ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 16:44:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            temporary_list . append ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // As long as the next input token is anything other than a <semicolon-token> or <EOF-token>,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // consume a component value and append it to the temporary list.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( ; ; )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  next_input_token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( next_input_token . is ( Token : : Type : : Semicolon )  | |  next_input_token . is ( Token : : Type : : EndOfFile ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                temporary_list . append ( consume_a_component_value ( tokens ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume a declaration from the temporary list. If anything was returned, append it to decls.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  token_stream  =  TokenStream ( temporary_list ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  maybe_declaration  =  consume_a_declaration ( token_stream ) ;  maybe_declaration . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                declarations . empend ( maybe_declaration . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <delim-token> with a value of "&" (U+0026 AMPERSAND)
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is_delim ( ' & ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 16:44:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume a qualified rule. If anything was returned, append it to rules.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  qualified_rule  =  consume_a_qualified_rule ( tokens ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                rules . empend ( qualified_rule ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // anything else
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // This is a parse error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // As long as the next input token is anything other than a <semicolon-token> or <EOF-token>,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // consume a component value and throw away the returned value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( ; ; )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  peek  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( peek . is ( Token : : Type : : Semicolon )  | |  peek . is ( Token : : Type : : EndOfFile ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                ( void ) consume_a_component_value ( tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < >  
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								ComponentValue  Parser : : consume_a_component_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This overload is called once tokens have already been converted into component values,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       so we do not need to do the work in the more general overload.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.4.7. Consume a component value
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-component-value
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								ComponentValue  Parser : : consume_a_component_value ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To consume a component value:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Consume the next input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // If the current input token is a <{-token>, <[-token>, or <(-token>, consume a simple block and return it.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is ( Token : : Type : : OpenCurly )  | |  token . is ( Token : : Type : : OpenSquare )  | |  token . is ( Token : : Type : : OpenParen ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ComponentValue ( consume_a_simple_block ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Otherwise, if the current input token is a <function-token>, consume a function and return it.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is ( Token : : Type : : Function ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ComponentValue ( consume_a_function ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:14:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Otherwise, return the current input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ComponentValue ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.4.8. Consume a simple block
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-simple-block
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-04-12 14:08:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								NonnullRefPtr < Block >  Parser : : consume_a_simple_block ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This algorithm assumes that the current input token has already been checked
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // to be an <{-token>, <[-token>, or <(-token>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // To consume a simple block:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The ending token is the mirror variant of the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // (E.g. if it was called with <[-token>, the ending token is <]-token>.)
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  ending_token  =  ( ( Token ) tokens . current_token ( ) ) . mirror_variant ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Create a simple block with its associated token set to the current input token
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // and with its value initially set to an empty list.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:05:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: We create the Block fully initialized when we return it instead.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Token  block_token  =  tokens . current_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  block_values ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Repeatedly consume the next input token and process it as follows:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // ending token
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( ending_token ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Return the block.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:05:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Block : : create ( move ( block_token ) ,  move ( block_values ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <EOF-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // This is a parse error. Return the block.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:20:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:05:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Block : : create ( move ( block_token ) ,  move ( block_values ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // anything else
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume a component value and append it to the value of the block.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:05:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            block_values . empend ( consume_a_component_value ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.4.9. Consume a function
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-function
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-04-12 13:35:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								NonnullRefPtr < Function >  Parser : : consume_a_function ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This algorithm assumes that the current input token has already been checked to be a <function-token>.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  name_ident  =  tokens . current_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( name_ident . is ( Token : : Type : : Function ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // To consume a function:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Create a function with its name equal to the value of the current input token
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // and with its value initially set to an empty list.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:44:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: We create the Function fully initialized when we return it instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-14 18:55:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  function_name  =  FlyString : : from_utf8 ( ( ( Token ) name_ident ) . function ( ) ) . release_value_but_fixme_should_propagate_errors ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:44:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  function_values ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Repeatedly consume the next input token and process it as follows:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <)-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : CloseParen ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Return the function.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:44:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Function : : create ( move ( function_name ) ,  move ( function_values ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <EOF-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // This is a parse error. Return the function.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:20:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:44:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Function : : create ( move ( function_name ) ,  move ( function_values ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // anything else
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								            // Consume a component value and append the returned value to the function’  
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:44:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            function_values . append ( consume_a_component_value ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:40:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:21:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.4.6. Consume a declaration
  
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-declaration
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-03-31 14:36:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Declaration >  Parser : : consume_a_declaration ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This algorithm assumes that the next input token has already been checked to
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // be an <ident-token>.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: This is not true in our implementation! For convenience, we both skip whitespace
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       and gracefully handle the first token not being an <ident-token>.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // To consume a declaration:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Consume the next input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: Not to spec, handle the case where the input token *isn't* an <ident-token>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! token . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 15:54:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Create a new declaration with its name set to the value of the current input token
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // and its value initially set to the empty list.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: We create a fully-initialized Declaration just before returning it instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-15 11:28:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  declaration_name  =  FlyString : : from_utf8 ( ( ( Token ) token ) . ident ( ) ) . release_value_but_fixme_should_propagate_errors ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  declaration_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Important  declaration_important  =  Important : : No ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. While the next input token is a <whitespace-token>, consume the next input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. If the next input token is anything other than a <colon-token>, this is a parse error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Return nothing.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  maybe_colon  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_colon . is ( Token : : Type : : Colon ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:20:14 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Otherwise, consume the next input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. While the next input token is a <whitespace-token>, consume the next input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. As long as the next input token is anything other than an <EOF-token>, consume a
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    //    component value and append it to the declaration’  
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( tokens . peek_token ( ) . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        declaration_values . append ( consume_a_component_value ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								    // 5. If the last two non-<whitespace-token>s in the declaration’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    with the value "!" followed by an <ident-token> with a value that is an ASCII case-insensitive
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    //    match for "important", remove them from the declaration’ ’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    important flag to true.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( declaration_values . size ( )  > =  2 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // Walk backwards from the end until we find "important"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Optional < size_t >  important_index ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( size_t  i  =  declaration_values . size ( )  -  1 ;  i  >  0 ;  i - - )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  value  =  declaration_values [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-17 15:21:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( value . is ( Token : : Type : : Ident )  & &  Infra : : is_ascii_case_insensitive_match ( value . token ( ) . ident ( ) ,  " important " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                important_index  =  i ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( value . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Walk backwards from important until we find "!"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( important_index . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Optional < size_t >  bang_index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( size_t  i  =  important_index . value ( )  -  1 ;  i  >  0 ;  i - - )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  value  =  declaration_values [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( value . is_delim ( ' ! ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    bang_index  =  i ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( value . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( bang_index . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                declaration_values . remove ( important_index . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                declaration_values . remove ( bang_index . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                declaration_important  =  Important : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								    // 6. While the last token in the declaration’  
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( ! declaration_values . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_whitespace  =  declaration_values . last ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! ( maybe_whitespace . is ( Token : : Type : : Whitespace ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:16:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        declaration_values . take_last ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-28 14:09:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Return the declaration.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  Declaration  {  move ( declaration_name ) ,  move ( declaration_values ) ,  declaration_important  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.4.5. Consume a list of declarations
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#consume-list-of-declarations
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Vector < DeclarationOrAtRule >  Parser : : consume_a_list_of_declarations ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To consume a list of declarations:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Create an initially empty list of declarations.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < DeclarationOrAtRule >  list_of_declarations ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Repeatedly consume the next input token:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <whitespace-token>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <semicolon-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Whitespace )  | |  token . is ( Token : : Type : : Semicolon ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Do nothing.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <EOF-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Return the list of declarations.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  list_of_declarations ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <at-keyword-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : AtKeyword ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume an at-rule. Append the returned rule to the list of declarations.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:22:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            list_of_declarations . empend ( consume_an_at_rule ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // <ident-token>
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Initialize a temporary list initially filled with the current input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < ComponentValue >  temporary_list ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            temporary_list . append ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // As long as the next input token is anything other than a <semicolon-token> or <EOF-token>,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // consume a component value and append it to the temporary list.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  peek  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( peek . is ( Token : : Type : : Semicolon )  | |  peek . is ( Token : : Type : : EndOfFile ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                temporary_list . append ( consume_a_component_value ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume a declaration from the temporary list. If anything was returned, append it to the list of declarations.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  token_stream  =  TokenStream ( temporary_list ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  maybe_declaration  =  consume_a_declaration ( token_stream ) ;  maybe_declaration . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 16:22:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                list_of_declarations . empend ( maybe_declaration . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // anything else
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // This is a parse error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 14:08:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Reconsume the current input token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // As long as the next input token is anything other than a <semicolon-token> or <EOF-token>,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // consume a component value and throw away the returned value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( ; ; )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  peek  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( peek . is ( Token : : Type : : Semicolon )  | |  peek . is ( Token : : Type : : EndOfFile ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " Discarding token: '{}' " ,  peek . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                ( void ) consume_a_component_value ( tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 15:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSRule *  Parser : : parse_as_css_rule ( )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_rule  =  parse_a_rule ( m_token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( maybe_rule ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  convert_to_rule ( maybe_rule . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.3.5. Parse a rule
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-rule
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < Rule >  Parser : : parse_a_rule ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a rule from input:
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-12 19:05:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < Rule >  rule ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This is done when initializing the Parser.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. While the next input token from input is a <whitespace-token>, consume the next input token from input.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If the next input token from input is an <EOF-token>, return a syntax error.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Otherwise, if the next input token from input is an <at-keyword-token>, consume an at-rule from input, and let rule be the return value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( token . is ( Token : : Type : : AtKeyword ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        rule  =  consume_an_at_rule ( m_token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Otherwise, consume a qualified rule from input and let rule be the return value. If nothing was returned, return a syntax error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  qualified_rule  =  consume_a_qualified_rule ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 16:34:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! qualified_rule ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        rule  =  qualified_rule ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. While the next input token from input is a <whitespace-token>, consume the next input token from input.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. If the next input token from input is an <EOF-token>, return rule. Otherwise, return a syntax error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . peek_token ( ) . is ( Token : : Type : : EndOfFile ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  rule ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 17:01:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.3.4. Parse a list of rules
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-list-of-rules
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2023-03-06 14:17:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector < NonnullRefPtr < Rule > >  Parser : : parse_a_list_of_rules ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-29 17:01:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a list of rules from input:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 16:34:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 17:01:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This is done when initializing the Parser.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 16:34:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 17:01:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Consume a list of rules from the input, with the top-level flag unset.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  list_of_rules  =  consume_a_list_of_rules ( tokens ,  TopLevel : : No ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Return the returned list.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  list_of_rules ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:56:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template  Vector < NonnullRefPtr < Rule > >  Parser : : parse_a_list_of_rules ( TokenStream < Token > &  tokens ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								template  Vector < NonnullRefPtr < Rule > >  Parser : : parse_a_list_of_rules ( TokenStream < ComponentValue > &  tokens ) ;  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:05:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < StyleProperty >  Parser : : parse_as_supports_condition ( )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:05:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_declaration  =  parse_a_declaration ( m_token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( maybe_declaration . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  convert_to_style_property ( maybe_declaration . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:05:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.3.6. Parse a declaration
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-a-declaration
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-03-31 14:36:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Declaration >  Parser : : parse_a_declaration ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:05:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a declaration from input:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This is done when initializing the Parser.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. While the next input token from input is a <whitespace-token>, consume the next input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:05:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If the next input token from input is not an <ident-token>, return a syntax error.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 21:47:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:06:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:05:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Consume a declaration from input. If anything was returned, return it. Otherwise, return a syntax error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  declaration  =  consume_a_declaration ( tokens ) ;  declaration . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  declaration . release_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 16:34:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 16:44:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								// 5.3.7. Parse a style block’   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-style-blocks-contents
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Vector < DeclarationOrAtRule >  Parser : : parse_a_style_blocks_contents ( TokenStream < T > &  tokens )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // To parse a style block’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This is done when initializing the Parser.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 2. Consume a style block’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  consume_a_style_blocks_contents ( tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.3.8. Parse a list of declarations
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-list-of-declarations
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector < DeclarationOrAtRule >  Parser : : parse_a_list_of_declarations ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a list of declarations from input:
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:23:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:23:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This is done when initializing the Parser.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Consume a list of declarations from input, and return the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  consume_a_list_of_declarations ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < ComponentValue >  Parser : : parse_as_component_value ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  parse_a_component_value ( m_token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:32:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.3.9. Parse a component value
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-component-value
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < ComponentValue >  Parser : : parse_a_component_value ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:32:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a component value from input:
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:32:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This is done when initializing the Parser.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:32:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. While the next input token from input is a <whitespace-token>, consume the next input token from input.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. If the next input token from input is an <EOF-token>, return a syntax error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . peek_token ( ) . is ( Token : : Type : : EndOfFile ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:32:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Consume a component value from input and let value be the return value.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  value  =  consume_a_component_value ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:32:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. While the next input token from input is a <whitespace-token>, consume the next input token.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:32:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. If the next input token from input is an <EOF-token>, return value. Otherwise, return a syntax error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . peek_token ( ) . is ( Token : : Type : : EndOfFile ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:39:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.3.10. Parse a list of component values
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-list-of-component-values
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector < ComponentValue >  Parser : : parse_a_list_of_component_values ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:39:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a list of component values from input:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This is done when initializing the Parser.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Repeatedly consume a component value from input until an <EOF-token> is returned, appending the returned values (except the final <EOF-token>) into a list. Return the list.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  component_values ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( tokens . peek_token ( ) . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:39:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        component_values . append ( consume_a_component_value ( tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:39:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  component_values ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:56:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// 5.3.11. Parse a comma-separated list of component values
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#parse-comma-separated-list-of-component-values
  
						 
					
						
							
								
									
										
										
										
											2021-07-03 15:40:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  T >  
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector < Vector < ComponentValue > >  Parser : : parse_a_comma_separated_list_of_component_values ( TokenStream < T > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:56:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // To parse a comma-separated list of component values from input:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Normalize input, and set input to the result.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: This is done when initializing the Parser.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let list of cvls be an initially empty list of component value lists.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < Vector < ComponentValue > >  list_of_component_value_lists ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:56:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Repeatedly consume a component value from input until an <EOF-token> or <comma-token> is returned,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    appending the returned values (except the final <EOF-token> or <comma-token>) into a list.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    Append the list to list of cvls.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    If it was a <comma-token> that was returned, repeat this step.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  current_list ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:56:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  component_value  =  consume_a_component_value ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:56:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( component_value . is ( Token : : Type : : EndOfFile ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            list_of_component_value_lists . append ( move ( current_list ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-02 19:52:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:56:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( component_value . is ( Token : : Type : : Comma ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            list_of_component_value_lists . append ( move ( current_list ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            current_list  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-02 19:52:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:56:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        current_list . append ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:56:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Return list of cvls.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  list_of_component_value_lists ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2023-07-15 09:32:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template  Vector < Vector < ComponentValue > >  Parser : : parse_a_comma_separated_list_of_component_values ( TokenStream < ComponentValue > & ) ;  
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:56:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template  Vector < Vector < ComponentValue > >  Parser : : parse_a_comma_separated_list_of_component_values ( TokenStream < Token > & ) ;  
						 
					
						
							
								
									
										
										
										
											2023-07-15 09:32:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 16:21:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								ElementInlineCSSStyleDeclaration *  Parser : : parse_as_style_attribute ( DOM : : Element &  element )  
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  declarations_and_at_rules  =  parse_a_list_of_declarations ( m_token_stream ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  [ properties ,  custom_properties ]  =  extract_properties ( declarations_and_at_rules ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ElementInlineCSSStyleDeclaration : : create ( element ,  move ( properties ) ,  move ( custom_properties ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 15:29:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < AK : : URL >  Parser : : parse_url_function ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Handle list of media queries. https://www.w3.org/TR/css-cascade-3/#conditional-import
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 08:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  convert_string_to_url  =  [ & ] ( StringView &  url_string )  - >  Optional < AK : : URL >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 15:29:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  url  =  m_context . complete_url ( url_string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( url . is_valid ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  url ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 17:02:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Url ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  url_string  =  component_value . token ( ) . url ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 08:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  convert_string_to_url ( url_string ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 17:02:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is_function ( )  & &  component_value . function ( ) . name ( ) . equals_ignoring_ascii_case ( " url " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  function_values  =  component_value . function ( ) . values ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Handle url-modifiers. https://www.w3.org/TR/css-values-4/#url-modifiers
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( size_t  i  =  0 ;  i  <  function_values . size ( ) ;  + + i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  value  =  function_values [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( value . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( value . is ( Token : : Type : : String ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 17:02:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  url_string  =  value . token ( ) . string ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-29 08:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  convert_string_to_url ( url_string ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 17:02:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_url_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2023-04-21 18:31:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-07-06 15:29:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  url  =  parse_url_function ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-21 18:31:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! url . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  URLStyleValue : : create ( * url ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-21 18:31:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < PositionValue >  Parser : : parse_position ( TokenStream < ComponentValue > &  tokens ,  PositionValue  initial_value )  
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_horizontal_preset  =  [ & ] ( auto  ident )  - >  Optional < PositionValue : : HorizontalPreset >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " left " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : HorizontalPreset : : Left ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " center " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : HorizontalPreset : : Center ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " right " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : HorizontalPreset : : Right ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_vertical_preset  =  [ & ] ( auto  ident )  - >  Optional < PositionValue : : VerticalPreset >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " top " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : VerticalPreset : : Top ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " center " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : VerticalPreset : : Center ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " bottom " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : VerticalPreset : : Bottom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_horizontal_edge  =  [ & ] ( auto  ident )  - >  Optional < PositionValue : : HorizontalEdge >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " left " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : HorizontalEdge : : Left ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " right " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : HorizontalEdge : : Right ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_vertical_edge  =  [ & ] ( auto  ident )  - >  Optional < PositionValue : : VerticalEdge >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " top " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : VerticalEdge : : Top ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " bottom " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PositionValue : : VerticalEdge : : Bottom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <position> = [
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   [ left | center | right ] || [ top | center | bottom ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   [ left | center | right | <length-percentage> ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   [ top | center | bottom | <length-percentage> ]?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   [ [ left | right ] <length-percentage> ] &&
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   [ [ top | bottom ] <length-percentage> ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // [ left | center | right ] || [ top | center | bottom ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  alternation_1  =  [ & ] ( )  - >  Optional < PositionValue >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        PositionValue  position  =  initial_value ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  first_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! first_token . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  first_token . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <horizontal-position> <vertical-position>?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  horizontal_position  =  parse_horizontal_preset ( ident ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( horizontal_position . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            position . horizontal_position  =  * horizontal_position ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  transaction_optional_parse  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  second_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( second_token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  vertical_position  =  parse_vertical_preset ( second_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( vertical_position . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        transaction_optional_parse . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        position . vertical_position  =  * vertical_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // <vertical-position> <horizontal-position>?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  vertical_position  =  parse_vertical_preset ( ident ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! vertical_position . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            position . vertical_position  =  * vertical_position ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  transaction_optional_parse  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  second_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( second_token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  horizontal_position  =  parse_horizontal_preset ( second_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( horizontal_position . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        transaction_optional_parse . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        position . horizontal_position  =  * horizontal_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // [ left | center | right | <length-percentage> ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // [ top | center | bottom | <length-percentage> ]?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  alternation_2  =  [ & ] ( )  - >  Optional < PositionValue >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        PositionValue  position  =  initial_value ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  first_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( first_token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  horizontal_position  =  parse_horizontal_preset ( first_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! horizontal_position . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            position . horizontal_position  =  * horizontal_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  dimension  =  parse_dimension ( first_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! dimension . has_value ( )  | |  ! dimension - > is_length_percentage ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            position . horizontal_position  =  dimension - > length_percentage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  transaction_optional_parse  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  second_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( second_token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  vertical_position  =  parse_vertical_preset ( second_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( vertical_position . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction_optional_parse . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    position . vertical_position  =  * vertical_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  dimension  =  parse_dimension ( second_token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 20:50:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( dimension . has_value ( )  & &  dimension - > is_length_percentage ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction_optional_parse . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    position . vertical_position  =  dimension - > length_percentage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:23:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // [ [ left | right ] <length-percentage> ] &&
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // [ [ top | bottom ] <length-percentage> ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  alternation_3  =  [ & ] ( )  - >  Optional < PositionValue >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PositionValue  position  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  parse_horizontal  =  [ & ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // [ left | right ] <length-percentage> ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  first_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! first_token . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  horizontal_egde  =  parse_horizontal_edge ( first_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! horizontal_egde . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            position . x_relative_to  =  * horizontal_egde ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  second_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  dimension  =  parse_dimension ( second_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! dimension . has_value ( )  | |  ! dimension - > is_length_percentage ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            position . horizontal_position  =  dimension - > length_percentage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  parse_vertical  =  [ & ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // [ top | bottom ] <length-percentage> ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  first_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! first_token . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  vertical_edge  =  parse_vertical_edge ( first_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! vertical_edge . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            position . y_relative_to  =  * vertical_edge ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  second_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  dimension  =  parse_dimension ( second_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! dimension . has_value ( )  | |  ! dimension - > is_length_percentage ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            position . vertical_position  =  dimension - > length_percentage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ( parse_horizontal ( )  & &  parse_vertical ( ) )  | |  ( parse_vertical ( )  & &  parse_horizontal ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: The alternatives must be attempted in this order since `alternation_2' can match a prefix of `alternation_3'
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  position  =  alternation_3 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! position . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        position  =  alternation_2 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! position . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        position  =  alternation_1 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( position . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 15:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSRule *  Parser : : convert_to_rule ( NonnullRefPtr < Rule >  rule )  
						 
					
						
							
								
									
										
										
										
											2021-07-09 16:34:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 16:42:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( rule - > is_at_rule ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( has_ignored_vendor_prefix ( rule - > at_rule_name ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:22:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( rule - > at_rule_name ( ) . equals_ignoring_ascii_case ( " font-face " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-14 21:36:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! rule - > block ( )  | |  ! rule - > block ( ) - > is_curly ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " @font-face rule is malformed. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-11 17:42:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-29 15:51:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  tokens  {  rule - > block ( ) - > values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  parse_font_face_rule ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( rule - > at_rule_name ( ) . equals_ignoring_ascii_case ( " import " sv )  & &  ! rule - > prelude ( ) . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 00:33:23 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Optional < AK : : URL >  url ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( auto  const &  token  :  rule - > prelude ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( token . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( token . is ( Token : : Type : : String ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    url  =  m_context . complete_url ( token . token ( ) . string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 17:41:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    url  =  parse_url_function ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 12:33:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                // FIXME: Handle list of media queries. https://www.w3.org/TR/css-cascade-3/#conditional-import
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( url . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:05:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( url . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  CSSImportRule : : create ( url . value ( ) ,  const_cast < DOM : : Document & > ( * m_context . document ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 15:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " Unable to parse url from @import rule " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:56:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( rule - > at_rule_name ( ) . equals_ignoring_ascii_case ( " media " sv ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  convert_to_media_rule ( rule ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( rule - > at_rule_name ( ) . equals_ignoring_ascii_case ( " supports " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 17:48:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  supports_tokens  =  TokenStream  {  rule - > prelude ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  supports  =  parse_a_supports ( supports_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! supports )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  constexpr  ( CSS_PARSER_DEBUG )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-05 16:16:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @supports rule invalid; discarding. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 17:48:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    supports_tokens . dump_all_tokens ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-11 17:42:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! rule - > block ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  child_tokens  =  TokenStream  {  rule - > block ( ) - > values ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-30 11:36:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  parser_rules  =  parse_a_list_of_rules ( child_tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 16:34:04 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            JS : : MarkedVector < CSSRule * >  child_rules ( m_context . realm ( ) . heap ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 17:48:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( auto &  raw_rule  :  parser_rules )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto *  child_rule  =  convert_to_rule ( raw_rule ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 15:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    child_rules . append ( child_rule ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-08 17:48:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  rule_list  =  CSSRuleList : : create ( m_context . realm ( ) ,  child_rules ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  CSSSupportsRule : : create ( m_context . realm ( ) ,  supports . release_nonnull ( ) ,  rule_list ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:05:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:30:54 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( rule - > at_rule_name ( ) . equals_ignoring_ascii_case ( " keyframes " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  prelude_stream  =  TokenStream  {  rule - > prelude ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            prelude_stream . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  token  =  prelude_stream . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! token . is_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @keyframes has invalid prelude, prelude = {}; discarding. " ,  rule - > prelude ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  name_token  =  token . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            prelude_stream . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( prelude_stream . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @keyframes has invalid prelude, prelude = {}; discarding. " ,  rule - > prelude ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 14:39:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( name_token . is ( Token : : Type : : Ident )  & &  ( is_css_wide_keyword ( name_token . ident ( ) )  | |  name_token . ident ( ) . equals_ignoring_ascii_case ( " none " sv ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:30:54 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @keyframes rule name is invalid: {}; discarding. " ,  name_token . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! name_token . is ( Token : : Type : : String )  & &  ! name_token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @keyframes rule name is invalid: {}; discarding. " ,  name_token . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 13:00:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  name  =  name_token . to_string ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:30:54 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! rule - > block ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  child_tokens  =  TokenStream  {  rule - > block ( ) - > values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 09:51:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            JS : : MarkedVector < JS : : NonnullGCPtr < CSSKeyframeRule > >  keyframes ( m_context . realm ( ) . heap ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:30:54 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            while  ( child_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                child_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // keyframe-selector = <keyframe-keyword> | <percentage>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // keyframe-keyword = "from" | "to"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // selector = <keyframe-selector>#
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // keyframes-block = "{" <declaration-list>? "}"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // keyframe-rule = <selector> <keyframes-block>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  selectors  =  Vector < CSS : : Percentage >  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                while  ( child_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    child_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( ! child_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  tok  =  child_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( ! tok . is_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @keyframes rule has invalid selector: {}; discarding. " ,  tok . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        child_tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  token  =  tok . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  read_a_selector  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        if  ( token . ident ( ) . equals_ignoring_ascii_case ( " from " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            selectors . append ( CSS : : Percentage ( 0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            read_a_selector  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        if  ( token . ident ( ) . equals_ignoring_ascii_case ( " to " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            selectors . append ( CSS : : Percentage ( 100 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            read_a_selector  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    }  else  if  ( token . is ( Token : : Type : : Percentage ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        selectors . append ( CSS : : Percentage ( token . percentage ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        read_a_selector  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( read_a_selector )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        child_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        if  ( child_tokens . next_token ( ) . is ( Token : : Type : : Comma ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    child_tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! child_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                child_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  token  =  child_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( token . is_block ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  block_tokens  =  token . block ( ) . values ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  block_stream  =  TokenStream  {  block_tokens  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  block_declarations  =  parse_a_list_of_declarations ( block_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  style  =  convert_to_style_declaration ( block_declarations ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    for  ( auto &  selector  :  selectors )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        auto  keyframe_rule  =  CSSKeyframeRule : : create ( m_context . realm ( ) ,  selector ,  * style ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:30:54 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        keyframes . append ( keyframe_rule ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @keyframes rule has invalid block: {}; discarding. " ,  token . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  CSSKeyframesRule : : create ( m_context . realm ( ) ,  name ,  move ( keyframes ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:30:54 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-29 11:51:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( rule - > at_rule_name ( ) . equals_ignoring_ascii_case ( " namespace " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // https://drafts.csswg.org/css-namespaces/#syntax
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  token_stream  =  TokenStream  {  rule - > prelude ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            token_stream . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  token  =  token_stream . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-07 17:29:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Optional < DeprecatedString >  prefix  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-29 11:51:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-07 00:22:33 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                prefix  =  token . token ( ) . ident ( ) . bytes_as_string_view ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-29 11:51:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                token_stream . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                token  =  token_stream . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            DeprecatedString  namespace_uri ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( token . is ( Token : : Type : : String ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                namespace_uri  =  token . token ( ) . string ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 15:29:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( auto  url  =  parse_url_function ( token ) ;  url . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-29 11:51:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                namespace_uri  =  url . value ( ) . to_deprecated_string ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @namespace rule invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            token_stream . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( token_stream . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @namespace rule invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  CSSNamespaceRule : : create ( m_context . realm ( ) ,  prefix ,  namespace_uri ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-29 11:51:15 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:05:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: More at rules!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " Unrecognized CSS at-rule: @{} " ,  rule - > at_rule_name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:05:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  prelude_stream  =  TokenStream ( rule - > prelude ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  selectors  =  parse_a_selector_list ( prelude_stream ,  SelectorType : : Standalone ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 17:47:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( selectors . is_error ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( selectors . error ( )  = =  ParseError : : SyntaxError )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: style rule selectors invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  constexpr  ( CSS_PARSER_DEBUG )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                prelude_stream . dump_all_tokens ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 17:47:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-23 16:13:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-23 16:13:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( selectors . value ( ) . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: empty selector; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! rule - > block ( ) - > is_curly ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  stream  =  TokenStream ( rule - > block ( ) - > values ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  declarations_and_at_rules  =  parse_a_style_blocks_contents ( stream ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-23 16:13:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto *  declaration  =  convert_to_style_declaration ( declarations_and_at_rules ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! declaration )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: style rule declaration invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  CSSStyleRule : : create ( m_context . realm ( ) ,  move ( selectors . value ( ) ) ,  * declaration ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 16:34:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								auto  Parser : : extract_properties ( Vector < DeclarationOrAtRule >  const &  declarations_and_at_rules )  - >  PropertiesAndCustomProperties  
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    PropertiesAndCustomProperties  result ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  declaration_or_at_rule  :  declarations_and_at_rules )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( declaration_or_at_rule . is_at_rule ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " !!! CSS at-rule is not allowed here! " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  declaration  =  declaration_or_at_rule . declaration ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_property  =  convert_to_style_property ( declaration ) ;  maybe_property . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  property  =  maybe_property . release_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( property . property_id  = =  PropertyID : : Custom )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                result . custom_properties . set ( property . custom_name ,  property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                result . properties . append ( move ( property ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:37:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:51:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								PropertyOwningCSSStyleDeclaration *  Parser : : convert_to_style_declaration ( Vector < DeclarationOrAtRule >  const &  declarations_and_at_rules )  
						 
					
						
							
								
									
										
										
										
											2022-03-29 16:01:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  [ properties ,  custom_properties ]  =  extract_properties ( declarations_and_at_rules ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  PropertyOwningCSSStyleDeclaration : : create ( m_context . realm ( ) ,  move ( properties ) ,  move ( custom_properties ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:32:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 14:36:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < StyleProperty >  Parser : : convert_to_style_property ( Declaration  const &  declaration )  
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:32:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-11-05 16:19:16 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  property_name  =  declaration . name ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:32:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  property_id  =  property_id_from_string ( property_name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 13:01:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! property_id . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-05 16:19:16 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( property_name . bytes_as_string_view ( ) . starts_with ( " -- " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:49:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            property_id  =  PropertyID : : Custom ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( has_ignored_vendor_prefix ( property_name ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-05 16:19:16 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( ! property_name . bytes_as_string_view ( ) . starts_with ( ' - ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-05 16:16:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " Unrecognized CSS property '{}' " ,  property_name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:49:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:32:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 14:41:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  value_token_stream  =  TokenStream ( declaration . values ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 13:01:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  value  =  parse_css_value ( property_id . value ( ) ,  value_token_stream ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( value . is_error ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . error ( )  = =  ParseError : : SyntaxError )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-05 16:16:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " Unable to parse value for CSS property '{}'. " ,  property_name ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-22 20:33:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  constexpr  ( CSS_PARSER_DEBUG )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                value_token_stream . dump_all_tokens ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-06 16:32:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 13:01:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( property_id . value ( )  = =  PropertyID : : Custom ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  StyleProperty  {  declaration . importance ( ) ,  property_id . value ( ) ,  value . release_value ( ) ,  declaration . name ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 13:01:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  StyleProperty  {  declaration . importance ( ) ,  property_id . value ( ) ,  value . release_value ( ) ,  { }  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_builtin_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  component_value . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " inherit " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  InheritStyleValue : : the ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " initial " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  InitialStyleValue : : the ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " unset " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  UnsetStyleValue : : the ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-29 17:14:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " revert " sv ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  RevertStyleValue : : the ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Implement `revert-layer` from CSS-CASCADE-5.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-19 15:45:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < CalculatedStyleValue >  Parser : : parse_calculated_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2022-01-25 14:45:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! component_value . is_function ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-25 14:45:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  function  =  component_value . function ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-30 20:56:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  function_node  =  parse_a_calc_function_node ( function ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! function_node ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:59:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  function_type  =  function_node - > determine_type ( m_context . current_property_id ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! function_type . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  CalculatedStyleValue : : create ( function_node . release_nonnull ( ) ,  function_type . release_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								OwnPtr < CalculationNode >  Parser : : parse_a_calc_function_node ( Function  const &  function )  
						 
					
						
							
								
									
										
										
										
											2023-05-30 20:56:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( function . name ( ) . equals_ignoring_ascii_case ( " calc " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  parse_a_calculation ( function . values ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-30 20:56:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  maybe_function  =  parse_math_function ( m_context . current_property_id ( ) ,  function ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-13 15:18:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  maybe_function ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-27 19:08:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-30 20:56:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 15:43:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Dimension >  Parser : : parse_dimension ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  numeric_value  =  component_value . token ( ) . dimension_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-18 12:04:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  unit_string  =  component_value . token ( ) . dimension_unit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 12:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  length_type  =  Length : : unit_from_name ( unit_string ) ;  length_type . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Length  {  numeric_value ,  length_type . release_value ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 12:48:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  angle_type  =  Angle : : unit_from_name ( unit_string ) ;  angle_type . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Angle  {  numeric_value ,  angle_type . release_value ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 15:18:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  flex_type  =  Flex : : unit_from_name ( unit_string ) ;  flex_type . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Flex  {  numeric_value ,  flex_type . release_value ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 12:48:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  frequency_type  =  Frequency : : unit_from_name ( unit_string ) ;  frequency_type . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Frequency  {  numeric_value ,  frequency_type . release_value ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  resolution_type  =  Resolution : : unit_from_name ( unit_string ) ;  resolution_type . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Resolution  {  numeric_value ,  resolution_type . release_value ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  time_type  =  Time : : unit_from_name ( unit_string ) ;  time_type . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Time  {  numeric_value ,  time_type . release_value ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Percentage ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  Percentage  {  component_value . token ( ) . percentage ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  numeric_value  =  component_value . token ( ) . number_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( numeric_value  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Length : : make_px ( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( m_context . in_quirks_mode ( )  & &  property_has_quirk ( m_context . current_property_id ( ) ,  Quirk : : UnitlessLength ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-11 20:48:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // https://quirks.spec.whatwg.org/#quirky-length-value
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Disallow quirk when inside a CSS sub-expression (like `calc()`)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // "The <quirky-length> value must not be supported in arguments to CSS expressions other than the rect()
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // expression, and must not be supported in the supports() static method of the CSS interface."
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-26 15:57:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Length : : make_px ( CSSPixels : : nearest_value_for ( numeric_value ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < LengthOrCalculated >  Parser : : parse_source_size_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Ident )  & &  component_value . token ( ) . ident ( ) . equals_ignoring_ascii_case ( " auto " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  LengthOrCalculated  {  Length : : make_auto ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  calculated_value  =  parse_calculated_value ( component_value ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  LengthOrCalculated  {  calculated_value . release_nonnull ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  length  =  parse_length ( component_value ) ;  length . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  LengthOrCalculated  {  length . release_value ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Length >  Parser : : parse_length ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  dimension  =  parse_dimension ( component_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! dimension . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( dimension - > is_length ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  dimension - > length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Ratio >  Parser : : parse_ratio ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2022-03-06 13:48:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 13:48:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  read_number_value  =  [ this ] ( ComponentValue  const &  component_value )  - >  Optional < double >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:59:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( component_value . is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  component_value . token ( ) . number_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( component_value . is_function ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_calc  =  parse_calculated_value ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_calc  | |  ! maybe_calc - > resolves_to_number ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:59:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  resolved_number  =  maybe_calc - > resolve_number ( ) ;  resolved_number . has_value ( )  & &  resolved_number . value ( )  > =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:59:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  resolved_number . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 13:48:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // `<ratio> = <number [0,∞]> [ / <number [0,∞]> ]?`
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:59:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_numerator  =  read_number_value ( tokens . next_token ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_numerator . has_value ( )  | |  maybe_numerator . value ( )  <  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:59:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  numerator  =  maybe_numerator . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 13:48:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  two_value_transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  solidus  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:59:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_denominator  =  read_number_value ( tokens . next_token ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( solidus . is_delim ( ' / ' )  & &  maybe_denominator . has_value ( )  & &  maybe_denominator . value ( )  > =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  denominator  =  maybe_denominator . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Two-value ratio
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            two_value_transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:59:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Ratio  {  numerator ,  denominator  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 13:48:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Single-value ratio
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:59:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  Ratio  {  numerator  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 13:48:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-syntax-3/#urange-syntax
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Optional < UnicodeRange >  Parser : : parse_unicode_range ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <urange> =
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u '+' <ident-token> '?'* |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u <dimension-token> '?'* |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u <number-token> '?'* |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u <number-token> <dimension-token> |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u <number-token> <number-token> |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u '+' '?'+
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // (All with no whitespace in between tokens.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: Parsing this is different from usual. We take these steps:
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Match the grammar above against the tokens, concatenating them into a string using their original representation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Then, parse that string according to the spec algorithm.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Step 2 is performed by calling the other parse_unicode_range() overload.
 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_ending_token  =  [ ] ( ComponentValue  const &  component_value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  component_value . is ( Token : : Type : : EndOfFile ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            | |  component_value . is ( Token : : Type : : Comma ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            | |  component_value . is ( Token : : Type : : Semicolon ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            | |  component_value . is ( Token : : Type : : Whitespace ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  create_unicode_range  =  [ & ] ( StringView  text ,  auto &  local_transaction )  - >  Optional < UnicodeRange >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_unicode_range  =  parse_unicode_range ( text ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( maybe_unicode_range . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            local_transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  maybe_unicode_range ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // All options start with 'u'/'U'.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  u  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! ( u . is ( Token : : Type : : Ident )  & &  u . token ( ) . ident ( ) . equals_ignoring_ascii_case ( " u " sv ) ) )  { 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> does not start with 'u' " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  second_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u '+' <ident-token> '?'* |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u '+' '?'+
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( second_token . is_delim ( ' + ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  local_transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        StringBuilder  string_builder ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        string_builder . append ( second_token . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  third_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( third_token . is ( Token : : Type : : Ident )  | |  third_token . is_delim ( ' ? ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            string_builder . append ( third_token . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            while  ( tokens . peek_token ( ) . is_delim ( ' ? ' ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                string_builder . append ( tokens . next_token ( ) . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( is_ending_token ( tokens . peek_token ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  create_unicode_range ( string_builder . string_view ( ) ,  local_transaction ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u <dimension-token> '?'*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( second_token . is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  local_transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        StringBuilder  string_builder ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        string_builder . append ( second_token . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        while  ( tokens . peek_token ( ) . is_delim ( ' ? ' ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            string_builder . append ( tokens . next_token ( ) . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_ending_token ( tokens . peek_token ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  create_unicode_range ( string_builder . string_view ( ) ,  local_transaction ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u <number-token> '?'* |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u <number-token> <dimension-token> |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  u <number-token> <number-token>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( second_token . is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  local_transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        StringBuilder  string_builder ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        string_builder . append ( second_token . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_ending_token ( tokens . peek_token ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  create_unicode_range ( string_builder . string_view ( ) ,  local_transaction ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  third_token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( third_token . is_delim ( ' ? ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            string_builder . append ( third_token . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            while  ( tokens . peek_token ( ) . is_delim ( ' ? ' ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                string_builder . append ( tokens . next_token ( ) . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( is_ending_token ( tokens . peek_token ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  create_unicode_range ( string_builder . string_view ( ) ,  local_transaction ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( third_token . is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            string_builder . append ( third_token . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( is_ending_token ( tokens . peek_token ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  create_unicode_range ( string_builder . string_view ( ) ,  local_transaction ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( third_token . is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-22 15:26:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            string_builder . append ( third_token . token ( ) . representation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( is_ending_token ( tokens . peek_token ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  create_unicode_range ( string_builder . string_view ( ) ,  local_transaction ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  constexpr  ( CSS_PARSER_DEBUG )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln ( " CSSParser: Tokens did not match <urange> grammar. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . dump_all_tokens ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < UnicodeRange >  Parser : : parse_unicode_range ( StringView  text )  
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  make_valid_unicode_range  =  [ & ] ( u32  start_value ,  u32  end_value )  - >  Optional < UnicodeRange >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // https://www.w3.org/TR/css-syntax-3/#maximum-allowed-code-point
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        constexpr  u32  maximum_allowed_code_point  =  0x10FFFF ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // To determine what codepoints the <urange> represents:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If end value is greater than the maximum allowed code point,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    the <urange> is invalid and a syntax error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( end_value  >  maximum_allowed_code_point )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: Invalid <urange>: end_value ({}) > maximum ({}) " ,  end_value ,  maximum_allowed_code_point ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If start value is greater than end value, the <urange> is invalid and a syntax error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( start_value  >  end_value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: Invalid <urange>: start_value ({}) > end_value ({}) " ,  start_value ,  end_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Otherwise, the <urange> represents a contiguous range of codepoints from start value to end value, inclusive.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  UnicodeRange  {  start_value ,  end_value  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Skipping the first u token, concatenate the representations of all the tokens in the production together.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    Let this be text.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: The concatenation is already done by the caller.
 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    GenericLexer  lexer  {  text  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. If the first character of text is U+002B PLUS SIGN, consume it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    Otherwise, this is an invalid <urange>, and this algorithm must exit.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( lexer . next_is ( ' + ' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        lexer . consume ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: Second character of <urange> was not '+'; got: '{}' " ,  lexer . consume ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Consume as many hex digits from text as possible.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    then consume as many U+003F QUESTION MARK (?) code points as possible.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  hex_digits  =  lexer . consume_while ( is_ascii_hex_digit ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  question_marks  =  lexer . consume_while ( [ ] ( auto  it )  {  return  it  = =  ' ? ' ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    If zero code points were consumed, or more than six code points were consumed,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    this is an invalid <urange>, and this algorithm must exit.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    size_t  consumed_code_points  =  hex_digits . length ( )  +  question_marks . length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( consumed_code_points  = =  0  | |  consumed_code_points  >  6 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> start value had {} digits/?s, expected between 1 and 6. " ,  consumed_code_points ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StringView  start_value_code_points  {  hex_digits . characters_without_null_termination ( ) ,  consumed_code_points  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    If any U+003F QUESTION MARK (?) code points were consumed, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( question_marks . length ( )  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. If there are any code points left in text, this is an invalid <urange>,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    and this algorithm must exit.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( lexer . tell_remaining ( )  ! =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> invalid; had {} code points left over. " ,  lexer . tell_remaining ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Interpret the consumed code points as a hexadecimal number,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    with the U+003F QUESTION MARK (?) code points replaced by U+0030 DIGIT ZERO (0) code points.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    This is the start value.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  start_value_string  =  start_value_code_points . replace ( " ? " sv ,  " 0 " sv ,  ReplaceMode : : All ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_start_value  =  AK : : StringUtils : : convert_to_uint_from_hex < u32 > ( start_value_string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_start_value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> ?-converted start value did not parse as hex number. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        u32  start_value  =  maybe_start_value . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Interpret the consumed code points as a hexadecimal number again,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    with the U+003F QUESTION MARK (?) code points replaced by U+0046 LATIN CAPITAL LETTER F (F) code points.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    This is the end value.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  end_value_string  =  start_value_code_points . replace ( " ? " sv ,  " F " sv ,  ReplaceMode : : All ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_end_value  =  AK : : StringUtils : : convert_to_uint_from_hex < u32 > ( end_value_string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_end_value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> ?-converted end value did not parse as hex number. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        u32  end_value  =  maybe_end_value . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Exit this algorithm.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  make_valid_unicode_range ( start_value ,  end_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   Otherwise, interpret the consumed code points as a hexadecimal number. This is the start value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_start_value  =  AK : : StringUtils : : convert_to_uint_from_hex < u32 > ( start_value_code_points ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_start_value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> start value did not parse as hex number. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    u32  start_value  =  maybe_start_value . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. If there are no code points left in text, The end value is the same as the start value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    Exit this algorithm.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( lexer . tell_remaining ( )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  make_valid_unicode_range ( start_value ,  start_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. If the next code point in text is U+002D HYPHEN-MINUS (-), consume it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( lexer . next_is ( ' - ' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        lexer . consume ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    Otherwise, this is an invalid <urange>, and this algorithm must exit.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> start and end values not separated by '-'. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 6. Consume as many hex digits as possible from text.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  end_hex_digits  =  lexer . consume_while ( is_ascii_hex_digit ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   If zero hex digits were consumed, or more than 6 hex digits were consumed,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   this is an invalid <urange>, and this algorithm must exit.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( end_hex_digits . length ( )  = =  0  | |  end_hex_digits . length ( )  >  6 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> end value had {} digits, expected between 1 and 6. " ,  end_hex_digits . length ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //   If there are any code points left in text, this is an invalid <urange>, and this algorithm must exit.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( lexer . tell_remaining ( )  ! =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> invalid; had {} code points left over. " ,  lexer . tell_remaining ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 7. Interpret the consumed code points as a hexadecimal number. This is the end value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_end_value  =  AK : : StringUtils : : convert_to_uint_from_hex < u32 > ( end_hex_digits ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_end_value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: <urange> end value did not parse as hex number. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 19:56:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Parse `<urange>` as CSS::UnicodeRange
Like, An+B, this is an old construct that does not fit well with modern
CSS syntax, so things get a bit hairy! We have to determine which
tokens match the grammar for `<urange>`, then turn those back into a
string, and then parse the string differently from normal. Thankfully
the spec describes in detail how to do that. :^)
This is not 100% correct, since we are not using the original source
text (referred to in the spec as the "representation") of the tokens,
but just converting them to strings in a manual, ad-hoc way.
Re-engineering the Tokenizer to keep that original text was too much of
a tangent for today. In any case, we do parse `U+4???`, `U+0-100`,
`U+1234`, and similar, so good enough for now!
											 
										 
										
											2022-04-07 17:41:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    u32  end_value  =  maybe_end_value . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  make_valid_unicode_range ( start_value ,  end_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_dimension_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
											 
										
											
												LibWeb: Make '0' always be both a number and a length in CSS
A '0' token can be interpreted both as a Number, and as a Length. This
is problematic as in our CSS parser, we often call parse_css_value()
first, to figure out what something is, and then assign it. So we do not
know in advance whether we want a Length or not. Previously, it always
got parsed as a Length, and then every place that expected a
NumericStyleValue had to also check for a Length(0), which is easy to
forget to do.
In particular, this was causing issues with the `flex` property parsing.
To solve this, we now always parse 0 as a NumericStyleValue, and NSVs of
0 pretend to be a Length(0px) when asked. In two places, we were casting
to a LengthStyleValue* based on is_length(), which no longer works, so
those have been adjusted to use `StyleValue::to_length()` instead. They
also now check for `is_numeric()` first, to avoid the extra conversion
to a Length and back.
Possibly this opens up new issues elsewhere. In my testing it seems
fine, but until we can get CSS test suites running, it's hard to know
for certain.
											 
										 
										
											2021-08-05 15:26:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Numbers with no units can be lengths, in two situations:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1) We're in quirks mode, and it's an integer.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 2) It's a 0.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // We handle case 1 here. Case 2 is handled by NumericStyleValue pretending to be a LengthStyleValue if it is 0.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 16:02:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 03:54:05 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Number )  & &  component_value . token ( ) . number_value ( )  ! =  0  & &  ! ( m_context . in_quirks_mode ( )  & &  property_has_quirk ( m_context . current_property_id ( ) ,  Quirk : : UnitlessLength ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  dimension  =  parse_dimension ( component_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! dimension . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 12:48:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( dimension - > is_angle ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  AngleStyleValue : : create ( dimension - > angle ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 12:48:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( dimension - > is_frequency ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  FrequencyStyleValue : : create ( dimension - > frequency ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( dimension - > is_length ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  LengthStyleValue : : create ( dimension - > length ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( dimension - > is_percentage ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  PercentageStyleValue : : create ( dimension - > percentage ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 12:48:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( dimension - > is_resolution ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ResolutionStyleValue : : create ( dimension - > resolution ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-22 12:48:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( dimension - > is_time ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  TimeStyleValue : : create ( dimension - > time ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 17:09:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_integer_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  peek_token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( peek_token . is ( Token : : Type : : Number )  & &  peek_token . token ( ) . number ( ) . is_integer ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  IntegerStyleValue : : create ( peek_token . token ( ) . number ( ) . integer_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_number_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  peek_token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( peek_token . is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:10:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  NumberStyleValue : : create ( peek_token . token ( ) . number ( ) . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_identifier_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  value_id  =  value_id_from_string ( component_value . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 12:43:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value_id . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  IdentifierStyleValue : : create ( value_id . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Color >  Parser : : parse_rgb_or_hsl_color ( StringView  function_name ,  Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Token  params [ 4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  legacy_syntax  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  component1  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! component1 . is ( Token : : Type : : Number ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  ! component1 . is ( Token : : Type : : Percentage ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        & &  ! component1 . is ( Token : : Type : : Dimension ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    params [ 0 ]  =  component1 . token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . peek_token ( ) . is ( Token : : Type : : Comma ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        legacy_syntax  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  component2  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! component2 . is ( Token : : Type : : Number )  & &  ! component2 . is ( Token : : Type : : Percentage ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    params [ 1 ]  =  component2 . token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( legacy_syntax  & &  ! tokens . next_token ( ) . is ( Token : : Type : : Comma ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 21:20:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  component3  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! component3 . is ( Token : : Type : : Number )  & &  ! component3 . is ( Token : : Type : : Percentage ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    params [ 2 ]  =  component3 . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  alpha_separator  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  has_comma  =  alpha_separator . is ( Token : : Type : : Comma ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  has_slash  =  alpha_separator . is_delim ( ' / ' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( legacy_syntax  ?  has_comma  :  has_slash )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  component4  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! component4 . is ( Token : : Type : : Number )  & &  ! component4 . is ( Token : : Type : : Percentage ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        params [ 3 ]  =  component4 . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( function_name . equals_ignoring_ascii_case ( " rgb " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        | |  function_name . equals_ignoring_ascii_case ( " rgba " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // https://www.w3.org/TR/css-color-4/#rgb-functions
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        u8  a_val  =  255 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( params [ 3 ] . is ( Token : : Type : : Number ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            a_val  =  clamp ( lround ( params [ 3 ] . number_value ( )  *  255.0 ) ,  0 ,  255 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( params [ 3 ] . is ( Token : : Type : : Percentage ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            a_val  =  clamp ( lround ( params [ 3 ] . percentage ( )  *  2.55 ) ,  0 ,  255 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( params [ 0 ] . is ( Token : : Type : : Number ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            & &  params [ 1 ] . is ( Token : : Type : : Number ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            & &  params [ 2 ] . is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:51:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            u8  r_val  =  clamp ( llroundf ( params [ 0 ] . number_value ( ) ) ,  0 ,  255 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            u8  g_val  =  clamp ( llroundf ( params [ 1 ] . number_value ( ) ) ,  0 ,  255 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            u8  b_val  =  clamp ( llroundf ( params [ 2 ] . number_value ( ) ) ,  0 ,  255 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Color ( r_val ,  g_val ,  b_val ,  a_val ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 21:20:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( params [ 0 ] . is ( Token : : Type : : Percentage ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            & &  params [ 1 ] . is ( Token : : Type : : Percentage ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            & &  params [ 2 ] . is ( Token : : Type : : Percentage ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 21:20:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            u8  r_val  =  lround ( clamp ( params [ 0 ] . percentage ( )  *  2.55 ,  0 ,  255 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            u8  g_val  =  lround ( clamp ( params [ 1 ] . percentage ( )  *  2.55 ,  0 ,  255 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            u8  b_val  =  lround ( clamp ( params [ 2 ] . percentage ( )  *  2.55 ,  0 ,  255 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Color ( r_val ,  g_val ,  b_val ,  a_val ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( function_name . equals_ignoring_ascii_case ( " hsl " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        | |  function_name . equals_ignoring_ascii_case ( " hsla " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // https://www.w3.org/TR/css-color-4/#the-hsl-notation
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  a_val  =  1.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( params [ 3 ] . is ( Token : : Type : : Number ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            a_val  =  params [ 3 ] . number_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( params [ 3 ] . is ( Token : : Type : : Percentage ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            a_val  =  params [ 3 ] . percentage ( )  /  100.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( params [ 0 ] . is ( Token : : Type : : Dimension ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            & &  params [ 1 ] . is ( Token : : Type : : Percentage ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            & &  params [ 2 ] . is ( Token : : Type : : Percentage ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 21:20:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  numeric_value  =  params [ 0 ] . dimension_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  unit_string  =  params [ 0 ] . dimension_unit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  angle_type  =  Angle : : unit_from_name ( unit_string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! angle_type . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 21:20:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  angle  =  Angle  {  numeric_value ,  angle_type . release_value ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            float  h_val  =  fmod ( angle . to_degrees ( ) ,  360.0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            float  s_val  =  params [ 1 ] . percentage ( )  /  100.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            float  l_val  =  params [ 2 ] . percentage ( )  /  100.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  Color : : from_hsla ( h_val ,  s_val ,  l_val ,  a_val ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( params [ 0 ] . is ( Token : : Type : : Number ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            & &  params [ 1 ] . is ( Token : : Type : : Percentage ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            & &  params [ 2 ] . is ( Token : : Type : : Percentage ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            float  h_val  =  fmod ( params [ 0 ] . number_value ( ) ,  360.0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            float  s_val  =  params [ 1 ] . percentage ( )  /  100.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            float  l_val  =  params [ 2 ] . percentage ( )  /  100.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Color : : from_hsla ( h_val ,  s_val ,  l_val ,  a_val ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/CSS2/visufx.html#value-def-shape
  
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_rect_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! component_value . is_function ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  function  =  component_value . function ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! function . name ( ) . equals_ignoring_ascii_case ( " rect " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < Length ,  4 >  params ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  function . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 23:31:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    enum  class  CommaRequirement  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Unknown , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        RequiresCommas , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        RequiresNoCommas 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    enum  class  Side  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Top  =  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Right  =  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Bottom  =  2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Left  =  3 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  comma_requirement  =  CommaRequirement : : Unknown ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // In CSS 2.1, the only valid <shape> value is: rect(<top>, <right>, <bottom>, <left>) where
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <top> and <bottom> specify offsets from the top border edge of the box, and <right>, and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //  <left> specify offsets from the left border edge of the box.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 23:31:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( size_t  side  =  0 ;  side  <  4 ;  side + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <top>, <right>, <bottom>, and <left> may either have a <length> value or 'auto'.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Negative lengths are permitted.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( current_token . is ( Token : : Type : : Ident )  & &  current_token . ident ( ) . equals_ignoring_ascii_case ( " auto " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            params . append ( Length : : make_auto ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_length  =  parse_length ( current_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_length . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            params . append ( maybe_length . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 23:31:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // The last side, should be no more tokens following it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( static_cast < Side > ( side )  = =  Side : : Left )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 23:31:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        bool  next_is_comma  =  tokens . peek_token ( ) . is ( Token : : Type : : Comma ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // Authors should separate offset values with commas. User agents must support separation
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // with commas, but may also support separation without commas (but not a combination),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // because a previous revision of this specification was ambiguous in this respect.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 23:31:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( comma_requirement  = =  CommaRequirement : : Unknown ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            comma_requirement  =  next_is_comma  ?  CommaRequirement : : RequiresCommas  :  CommaRequirement : : RequiresNoCommas ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( comma_requirement  = =  CommaRequirement : : RequiresCommas )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( next_is_comma ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            else 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 23:31:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( comma_requirement  = =  CommaRequirement : : RequiresNoCommas )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( next_is_comma ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 23:31:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 23:31:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  RectStyleValue : : create ( EdgeRect  {  params [ 0 ] ,  params [ 1 ] ,  params [ 2 ] ,  params [ 3 ]  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-31 18:46:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Color >  Parser : : parse_color ( ComponentValue  const &  component_value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://www.w3.org/TR/css-color-4/
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  component_value . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  color  =  Color : : from_string ( ident ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( color . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  color ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( component_value . is ( Token : : Type : : Hash ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 18:02:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  color  =  Color : : from_string ( DeprecatedString : : formatted ( " #{} " ,  component_value . token ( ) . hash_value ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( color . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  color ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( component_value . is_function ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  function  =  component_value . function ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  values  =  function . values ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-09 19:08:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  parse_rgb_or_hsl_color ( function . name ( ) ,  values ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 17:41:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( m_context . in_quirks_mode ( )  & &  property_has_quirk ( m_context . current_property_id ( ) ,  Quirk : : HashlessHexColor ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // The value of a quirky color is obtained from the possible component values using the following algorithm,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // aborting on the first step that returns a value:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Let cv be the component value.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  cv  =  component_value ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 18:02:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        DeprecatedString  serialization ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If cv is a <number-token> or a <dimension-token>, follow these substeps:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( cv . is ( Token : : Type : : Number )  | |  cv . is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // 1. If cv’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    This means that values that happen to use scientific notation, e.g., 5e5e5e, will fail to parse.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 21:01:27 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! cv . token ( ) . number ( ) . is_integer ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // 2. If cv’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  value  =  cv . is ( Token : : Type : : Number )  ?  cv . token ( ) . to_integer ( )  :  cv . token ( ) . dimension_value_int ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( value  <  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // 3. Let serialization be the serialization of cv’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            StringBuilder  serialization_builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            serialization_builder . appendff ( " {} " ,  value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 4. If cv is a <dimension-token>, append the unit to serialization.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( cv . is ( Token : : Type : : Dimension ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                serialization_builder . append ( cv . token ( ) . dimension_unit ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // 5. If serialization consists of fewer than six characters, prepend zeros (U+0030) so that it becomes six characters.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-06 01:12:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            serialization  =  serialization_builder . to_deprecated_string ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( serialization_builder . length ( )  <  6 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                StringBuilder  builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                for  ( size_t  i  =  0 ;  i  <  ( 6  -  serialization_builder . length ( ) ) ;  i + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    builder . append ( ' 0 ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                builder . append ( serialization_builder . string_view ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-06 01:12:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                serialization  =  builder . to_deprecated_string ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								        // 3. Otherwise, cv is an <ident-token>; let serialization be cv’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! cv . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-07 00:22:33 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            serialization  =  cv . token ( ) . ident ( ) . bytes_as_string_view ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. If serialization does not consist of three or six characters, return an error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( serialization . length ( )  ! =  3  & &  serialization . length ( )  ! =  6 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 5. If serialization contains any characters not in the range [0-9A-Fa-f] (U+0030 to U+0039, U+0041 to U+0046, U+0061 to U+0066), return an error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  c  :  serialization )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! ( ( c  > =  ' 0 '  & &  c  < =  ' 9 ' )  | |  ( c  > =  ' A '  & &  c  < =  ' F ' )  | |  ( c  > =  ' a '  & &  c  < =  ' f ' ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 6. Return the concatenation of "#" (U+0023) and serialization.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 18:02:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        DeprecatedString  concatenation  =  DeprecatedString : : formatted ( " #{} " ,  serialization ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-23 13:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  Color : : from_string ( concatenation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_color_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:10:03 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-11-05 17:41:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  color  =  parse_color ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( color . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ColorStyleValue : : create ( color . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-09 21:04:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 17:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-23 15:40:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  value_id_from_string ( component_value . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . has_value ( )  & &  IdentifierStyleValue : : is_color ( ident . value ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  IdentifierStyleValue : : create ( ident . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 17:34:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_ratio_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2023-06-06 15:42:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  ratio  =  parse_ratio ( tokens ) ;  ratio . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  RatioStyleValue : : create ( ratio . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_string_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2021-07-18 17:12:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is ( Token : : Type : : String ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  StringStyleValue : : create ( MUST ( String : : from_utf8 ( component_value . token ( ) . string ( ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-08 21:53:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-07-08 13:44:01 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_image_value ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2021-07-22 13:00:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-07-06 15:29:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  url  =  parse_url_function ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 17:51:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( url . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ImageStyleValue : : create ( url . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  linear_gradient  =  parse_linear_gradient_function ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 19:25:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( linear_gradient ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  linear_gradient ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  conic_gradient  =  parse_conic_gradient_function ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 19:12:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( conic_gradient ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  conic_gradient ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  parse_radial_gradient_function ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-22 13:00:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-15 16:37:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint
  
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_paint_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2023-06-15 16:37:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // `<paint> = none | <color> | <url> [none | <color>]? | context-fill | context-stroke`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_color_or_none  =  [ & ] ( )  - >  Optional < RefPtr < StyleValue > >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  color  =  parse_color_value ( tokens . peek_token ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:52:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  color ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-16 14:12:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:52:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: <color> also accepts identifiers, so we do this identifier check last.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( tokens . peek_token ( ) . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_ident  =  value_id_from_string ( tokens . peek_token ( ) . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( maybe_ident . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // FIXME: Accept `context-fill` and `context-stroke`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                switch  ( * maybe_ident )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  ValueID : : None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  IdentifierStyleValue : : create ( * maybe_ident ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-15 16:37:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:52:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  OptionalNone  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIMXE: Allow context-fill/context-stroke here
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  color_or_none  =  parse_color_or_none ( ) ;  color_or_none . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:52:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  * color_or_none ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  url  =  parse_url_value ( tokens . peek_token ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:52:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  color_or_none  =  parse_color_or_none ( ) ;  color_or_none  = =  nullptr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 13:52:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Fail to parse if the fallback is invalid, but otherwise ignore it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Use fallback color
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  url ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-15 16:37:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								template < typename  ParseFunction >  
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_comma_separated_value_list ( Vector < ComponentValue >  const &  component_values ,  ParseFunction  parse_one_value )  
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  first  =  parse_one_value ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! first  | |  ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  first ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-20 00:41:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  values ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    values . append ( first . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! tokens . next_token ( ) . is ( Token : : Type : : Comma ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_value  =  parse_one_value ( tokens ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            values . append ( maybe_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  StyleValueList : : create ( move ( values ) ,  StyleValueList : : Separator : : Comma ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_simple_comma_separated_value_list ( PropertyID  property_id ,  Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  parse_comma_separated_value_list ( component_values ,  [ = ,  this ] ( auto &  tokens )  - >  RefPtr < StyleValue >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  value  =  parse_css_value_for_property ( property_id ,  tokens ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  void  remove_property ( Vector < PropertyID > &  properties ,  PropertyID  property_to_remove )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    properties . remove_first_matching ( [ & ] ( auto  it )  {  return  it  = =  property_to_remove ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 15:25:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-sizing-4/#aspect-ratio
  
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_aspect_ratio_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-06-08 15:25:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // `auto || <ratio>`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  auto_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  ratio_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_value  =  parse_css_value_for_property ( PropertyID : : AspectRatio ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 15:25:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( maybe_value - > is_ratio ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ratio_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            ratio_value  =  maybe_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( maybe_value - > is_identifier ( )  & &  maybe_value - > as_identifier ( ) . id ( )  = =  ValueID : : Auto )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto_value  =  maybe_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto_value  & &  ratio_value )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  StyleValueList : : create ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 15:25:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueVector  {  auto_value . release_nonnull ( ) ,  ratio_value . release_nonnull ( )  } , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueList : : Separator : : Space ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 15:25:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ratio_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ratio_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  auto_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_background_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-10 16:20:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-09-19 15:27:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  make_background_shorthand  =  [ & ] ( auto  background_color ,  auto  background_image ,  auto  background_position ,  auto  background_size ,  auto  background_repeat ,  auto  background_attachment ,  auto  background_origin ,  auto  background_clip )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( PropertyID : : Background , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  PropertyID : : BackgroundColor ,  PropertyID : : BackgroundImage ,  PropertyID : : BackgroundPosition ,  PropertyID : : BackgroundSize ,  PropertyID : : BackgroundRepeat ,  PropertyID : : BackgroundAttachment ,  PropertyID : : BackgroundOrigin ,  PropertyID : : BackgroundClip  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  move ( background_color ) ,  move ( background_image ) ,  move ( background_position ) ,  move ( background_size ) ,  move ( background_repeat ) ,  move ( background_attachment ) ,  move ( background_origin ) ,  move ( background_clip )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-20 00:41:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  background_images ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  background_positions ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  background_sizes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  background_repeats ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  background_attachments ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  background_clips ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  background_origins ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  background_color ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_background_image  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : BackgroundImage ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_background_position  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : BackgroundPosition ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_background_size  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : BackgroundSize ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_background_repeat  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : BackgroundRepeat ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_background_attachment  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : BackgroundAttachment ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_background_clip  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : BackgroundClip ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_background_origin  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : BackgroundOrigin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  initial_background_color  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : BackgroundColor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Per-layer values
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  background_image ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 16:30:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  background_position ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 16:15:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  background_size ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  background_repeat ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 17:46:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  background_attachment ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  background_clip ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  background_origin ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  has_multiple_layers  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // BackgroundSize is always parsed as part of BackgroundPosition, so we don't include it here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < PropertyID >  remaining_layer_properties  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PropertyID : : BackgroundAttachment , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PropertyID : : BackgroundClip , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PropertyID : : BackgroundColor , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PropertyID : : BackgroundImage , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PropertyID : : BackgroundOrigin , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PropertyID : : BackgroundPosition , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PropertyID : : BackgroundRepeat , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  background_layer_is_valid  =  [ & ] ( bool  allow_background_color )  - >  bool  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( allow_background_color )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( background_color ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( background_color ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  background_image  | |  background_position  | |  background_size  | |  background_repeat  | |  background_attachment  | |  background_clip  | |  background_origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  complete_background_layer  =  [ & ] ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_images . append ( background_image  ?  background_image . release_nonnull ( )  :  initial_background_image ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_positions . append ( background_position  ?  background_position . release_nonnull ( )  :  initial_background_position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_sizes . append ( background_size  ?  background_size . release_nonnull ( )  :  initial_background_size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_repeats . append ( background_repeat  ?  background_repeat . release_nonnull ( )  :  initial_background_repeat ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_attachments . append ( background_attachment  ?  background_attachment . release_nonnull ( )  :  initial_background_attachment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! background_origin  & &  ! background_clip )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            background_origin  =  initial_background_origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            background_clip  =  initial_background_clip ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( ! background_clip )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            background_clip  =  background_origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_origins . append ( background_origin . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_clips . append ( background_clip . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_image  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_position  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_size  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_repeat  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_attachment  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_clip  =  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_origin  =  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 15:09:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        remaining_layer_properties . clear_with_capacity ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remaining_layer_properties . unchecked_append ( PropertyID : : BackgroundAttachment ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remaining_layer_properties . unchecked_append ( PropertyID : : BackgroundClip ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remaining_layer_properties . unchecked_append ( PropertyID : : BackgroundColor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remaining_layer_properties . unchecked_append ( PropertyID : : BackgroundImage ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remaining_layer_properties . unchecked_append ( PropertyID : : BackgroundOrigin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remaining_layer_properties . unchecked_append ( PropertyID : : BackgroundPosition ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remaining_layer_properties . unchecked_append ( PropertyID : : BackgroundRepeat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 16:30:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( tokens . peek_token ( ) . is ( Token : : Type : : Comma ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            has_multiple_layers  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! background_layer_is_valid ( false ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            complete_background_layer ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  value_and_property  =  parse_css_value_for_properties ( remaining_layer_properties ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! value_and_property . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  value  =  value_and_property - > style_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remove_property ( remaining_layer_properties ,  value_and_property - > property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( value_and_property - > property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : BackgroundAttachment : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! background_attachment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 17:46:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            background_attachment  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : BackgroundColor : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! background_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            background_color  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : BackgroundImage : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! background_image ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            background_image  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : BackgroundClip : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : BackgroundOrigin :  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // background-origin and background-clip accept the same values. From the spec:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //   "If one <box> value is present then it sets both background-origin and background-clip to that value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //    If two values are present, then the first sets background-origin and the second background-clip."
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //        - https://www.w3.org/TR/css-backgrounds-3/#background
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // So, we put the first one in background-origin, then if we get a second, we put it in background-clip.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 15:27:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // If we only get one, we copy the value before creating the ShorthandStyleValue.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! background_origin )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                background_origin  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( ! background_clip )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                background_clip  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : BackgroundPosition :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! background_position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 16:30:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  maybe_background_position  =  parse_single_background_position_value ( tokens ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 16:30:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                background_position  =  maybe_background_position . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 16:15:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // Attempt to parse `/ <background-size>`
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 16:15:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  maybe_slash  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( maybe_slash . is_delim ( ' / ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( auto  maybe_background_size  =  parse_single_background_size_value ( tokens ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 16:15:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        background_size  =  maybe_background_size . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 16:30:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : BackgroundRepeat :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! background_repeat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  maybe_repeat  =  parse_single_background_repeat_value ( tokens ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                background_repeat  =  maybe_repeat . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:50:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! background_layer_is_valid ( true ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // We only need to create StyleValueLists if there are multiple layers.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Otherwise, we can pass the single StyleValues directly.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( has_multiple_layers )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        complete_background_layer ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! background_color ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            background_color  =  initial_background_color ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 15:27:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  make_background_shorthand ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            background_color . release_nonnull ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueList : : create ( move ( background_images ) ,  StyleValueList : : Separator : : Comma ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueList : : create ( move ( background_positions ) ,  StyleValueList : : Separator : : Comma ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueList : : create ( move ( background_sizes ) ,  StyleValueList : : Separator : : Comma ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueList : : create ( move ( background_repeats ) ,  StyleValueList : : Separator : : Comma ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueList : : create ( move ( background_attachments ) ,  StyleValueList : : Separator : : Comma ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueList : : create ( move ( background_origins ) ,  StyleValueList : : Separator : : Comma ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            StyleValueList : : create ( move ( background_clips ) ,  StyleValueList : : Separator : : Comma ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 11:12:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! background_color ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_color  =  initial_background_color ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! background_image ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_image  =  initial_background_image ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 16:30:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! background_position ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_position  =  initial_background_position ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 16:15:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! background_size ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_size  =  initial_background_size ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! background_repeat ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_repeat  =  initial_background_repeat ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 17:46:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! background_attachment ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_attachment  =  initial_background_attachment ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! background_origin  & &  ! background_clip )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 13:03:56 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_origin  =  initial_background_origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_clip  =  initial_background_clip ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( ! background_clip )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_clip  =  background_origin ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 15:27:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  make_background_shorthand ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_color . release_nonnull ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_image . release_nonnull ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_position . release_nonnull ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 16:15:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_size . release_nonnull ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_repeat . release_nonnull ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-03 20:28:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_attachment . release_nonnull ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        background_origin . release_nonnull ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        background_clip . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  Optional < LengthPercentage >  style_value_to_length_percentage ( auto  value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( value - > is_percentage ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  LengthPercentage  {  value - > as_percentage ( ) . percentage ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-27 12:28:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( value - > is_length ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  LengthPercentage  {  value - > as_length ( ) . length ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( value - > is_calculated ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  LengthPercentage  {  value - > as_calculated ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-07 22:48:11 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_single_background_position_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: This *looks* like it parses a <position>, but it doesn't. From the spec:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      "Note: The background-position property also accepts a three-value syntax.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       This has been disallowed generically because it creates parsing ambiguities
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       when combined with other length or percentage components in a property value."
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //           - https://www.w3.org/TR/css-values-4/#typedef-position
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       So, we'll need a separate function to parse <position> later.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_horizontal  =  [ ] ( ValueID  identifier )  - >  bool  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( identifier )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : Left : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : Right : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_vertical  =  [ ] ( ValueID  identifier )  - >  bool  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( identifier )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : Top : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : Bottom : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    struct  EdgeOffset  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        PositionEdge  edge ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 11:20:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        LengthPercentage  offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        bool  edge_provided ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        bool  offset_provided ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < EdgeOffset >  horizontal ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < EdgeOffset >  vertical ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  found_center  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 11:51:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const  center_offset  =  Percentage  {  50  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const  zero_offset  =  Length : : make_px ( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Check if we're done
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  seen_items  =  ( horizontal . has_value ( )  ?  1  :  0 )  +  ( vertical . has_value ( )  ?  1  :  0 )  +  ( found_center  ?  1  :  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( seen_items  = =  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_value  =  parse_css_value_for_property ( PropertyID : : BackgroundPosition ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:46:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_value ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  value  =  maybe_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:46:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  offset  =  style_value_to_length_percentage ( value ) ;  offset . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 11:20:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! horizontal . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 11:51:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                horizontal  =  EdgeOffset  {  PositionEdge : : Left ,  * offset ,  false ,  true  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 11:20:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( ! vertical . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 11:51:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                vertical  =  EdgeOffset  {  PositionEdge : : Top ,  * offset ,  false ,  true  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 11:20:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-19 11:20:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  try_parse_offset  =  [ & ] ( bool &  offset_provided )  - >  LengthPercentage  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:46:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 11:51:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  maybe_value  =  parse_css_value_for_property ( PropertyID : : BackgroundPosition ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 11:51:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! maybe_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  zero_offset ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  offset  =  style_value_to_length_percentage ( maybe_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 11:51:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( offset . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    offset_provided  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:46:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 11:51:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  * offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-11 11:51:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  zero_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 12:00:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value - > is_identifier ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  identifier  =  value - > to_identifier ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( is_horizontal ( identifier ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                bool  offset_provided  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  offset  =  try_parse_offset ( offset_provided ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-02 16:02:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                horizontal  =  EdgeOffset  {  * value_id_to_position_edge ( identifier ) ,  offset ,  true ,  offset_provided  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( is_vertical ( identifier ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                bool  offset_provided  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  offset  =  try_parse_offset ( offset_provided ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-02 16:02:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                vertical  =  EdgeOffset  {  * value_id_to_position_edge ( identifier ) ,  offset ,  true ,  offset_provided  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( identifier  = =  ValueID : : Center )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                found_center  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( found_center )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( horizontal . has_value ( )  & &  vertical . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! horizontal . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            horizontal  =  EdgeOffset  {  PositionEdge : : Left ,  center_offset ,  true ,  false  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! vertical . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            vertical  =  EdgeOffset  {  PositionEdge : : Top ,  center_offset ,  true ,  false  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! horizontal . has_value ( )  & &  ! vertical . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Unpack `<edge> <length>`:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The loop above reads this pattern as a single EdgeOffset, when actually, it should be treated
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // as `x y` if the edge is horizontal, and `y` (with the second token reconsumed) otherwise.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! vertical . has_value ( )  & &  horizontal - > edge_provided  & &  horizontal - > offset_provided )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Split into `x y`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        vertical  =  EdgeOffset  {  PositionEdge : : Top ,  horizontal - > offset ,  false ,  true  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        horizontal - > offset  =  zero_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        horizontal - > offset_provided  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( ! horizontal . has_value ( )  & &  vertical - > edge_provided  & &  vertical - > offset_provided )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // `y`, reconsume
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        vertical - > offset  =  zero_offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        vertical - > offset_provided  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // If only one value is specified, the second value is assumed to be center.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! horizontal . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        horizontal  =  EdgeOffset  {  PositionEdge : : Left ,  center_offset ,  false ,  false  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! vertical . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        vertical  =  EdgeOffset  {  PositionEdge : : Top ,  center_offset ,  false ,  false  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  PositionStyleValue : : create ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        EdgeStyleValue : : create ( horizontal - > edge ,  horizontal - > offset ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        EdgeStyleValue : : create ( vertical - > edge ,  vertical - > offset ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_single_background_position_x_or_y_value ( TokenStream < ComponentValue > &  tokens ,  PropertyID  property )  
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    PositionEdge  relative_edge  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( property  = =  PropertyID : : BackgroundPositionX )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // [ center | [ [ left | right | x-start | x-end ]? <length-percentage>? ]! ]#
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        relative_edge  =  PositionEdge : : Left ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( property  = =  PropertyID : : BackgroundPositionY )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // [ center | [ [ top | bottom | y-start | y-end ]? <length-percentage>? ]! ]#
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        relative_edge  =  PositionEdge : : Top ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  value  =  parse_css_value_for_property ( property ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:46:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 12:00:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( value - > is_identifier ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  identifier  =  value - > to_identifier ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( identifier  = =  ValueID : : Center )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  EdgeStyleValue : : create ( relative_edge ,  Percentage  {  50  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-02 16:02:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  edge  =  value_id_to_position_edge ( identifier ) ;  edge . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            relative_edge  =  * edge ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            value  =  parse_css_value_for_property ( property ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  EdgeStyleValue : : create ( relative_edge ,  Length : : make_px ( 0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  offset  =  style_value_to_length_percentage ( value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( offset . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  EdgeStyleValue : : create ( relative_edge ,  * offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 22:49:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // If no offset is provided create this element but with an offset of default value of zero
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  EdgeStyleValue : : create ( relative_edge ,  Length : : make_px ( 0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_single_background_repeat_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-08-10 10:21:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 10:21:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_directional_repeat  =  [ ] ( StyleValue  const &  value )  - >  bool  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  value_id  =  value . to_identifier ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  value_id  = =  ValueID : : RepeatX  | |  value_id  = =  ValueID : : RepeatY ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 20:10:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  as_repeat  =  [ ] ( ValueID  identifier )  - >  Optional < Repeat >  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 17:38:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( identifier )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : NoRepeat : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Repeat : : NoRepeat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : Repeat : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Repeat : : Repeat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : Round : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Repeat : : Round ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : Space : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  Repeat : : Space ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 20:10:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 17:38:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_x_value  =  parse_css_value_for_property ( PropertyID : : BackgroundRepeat ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:43:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_x_value ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  x_value  =  maybe_x_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 10:21:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_directional_repeat ( * x_value ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  value_id  =  x_value - > to_identifier ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  BackgroundRepeatStyleValue : : create ( 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 17:38:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            value_id  = =  ValueID : : RepeatX  ?  Repeat : : Repeat  :  Repeat : : NoRepeat , 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            value_id  = =  ValueID : : RepeatX  ?  Repeat : : NoRepeat  :  Repeat : : Repeat ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 10:21:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 20:10:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  x_repeat  =  as_repeat ( x_value - > to_identifier ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! x_repeat . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // See if we have a second value for Y
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_y_value  =  parse_css_value_for_property ( PropertyID : : BackgroundRepeat ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:43:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_y_value )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // We don't have a second value, so use x for both
 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  BackgroundRepeatStyleValue : : create ( x_repeat . value ( ) ,  x_repeat . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 10:21:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  y_value  =  maybe_y_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_directional_repeat ( * y_value ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-03 20:10:18 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  y_repeat  =  as_repeat ( y_value - > to_identifier ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! y_repeat . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  BackgroundRepeatStyleValue : : create ( x_repeat . value ( ) ,  y_repeat . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-04 15:56:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-08-10 10:21:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_single_background_size_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-01-16 20:24:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  get_length_percentage  =  [ ] ( StyleValue &  style_value )  - >  Optional < LengthPercentage >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-17 19:53:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( style_value . has_auto ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  LengthPercentage  {  Length : : make_auto ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-16 20:24:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( style_value . is_percentage ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  LengthPercentage  {  style_value . as_percentage ( ) . percentage ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-27 12:28:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( style_value . is_length ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  LengthPercentage  {  style_value . as_length ( ) . length ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-11 21:36:18 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( style_value . is_calculated ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  LengthPercentage  {  style_value . as_calculated ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-16 20:24:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_x_value  =  parse_css_value_for_property ( PropertyID : : BackgroundSize ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:49:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_x_value ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  x_value  =  maybe_x_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-06-25 16:54:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( x_value - > to_identifier ( )  = =  ValueID : : Cover  | |  x_value - > to_identifier ( )  = =  ValueID : : Contain )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  x_value ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-06-25 16:54:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_y_value  =  parse_css_value_for_property ( PropertyID : : BackgroundSize ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 15:49:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_y_value )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-14 10:42:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  y_value  =  LengthPercentage  {  Length : : make_auto ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-16 20:24:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  x_size  =  get_length_percentage ( * x_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! x_size . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-14 10:42:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  BackgroundSizeStyleValue : : create ( x_size . value ( ) ,  y_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-16 20:24:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  y_value  =  maybe_y_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-16 20:24:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  x_size  =  get_length_percentage ( * x_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  y_size  =  get_length_percentage ( * y_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! x_size . has_value ( )  | |  ! y_size . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  BackgroundSizeStyleValue : : create ( x_size . release_value ( ) ,  y_size . release_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_border_value ( PropertyID  property_id ,  Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  >  3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  border_width ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  border_color ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  border_style ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  color_property  =  PropertyID : : Invalid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  style_property  =  PropertyID : : Invalid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  width_property  =  PropertyID : : Invalid ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    switch  ( property_id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Border : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        color_property  =  PropertyID : : BorderColor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        style_property  =  PropertyID : : BorderStyle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        width_property  =  PropertyID : : BorderWidth ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderBottom : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        color_property  =  PropertyID : : BorderBottomColor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        style_property  =  PropertyID : : BorderBottomStyle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        width_property  =  PropertyID : : BorderBottomWidth ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderLeft : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        color_property  =  PropertyID : : BorderLeftColor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        style_property  =  PropertyID : : BorderLeftStyle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        width_property  =  PropertyID : : BorderLeftWidth ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderRight : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        color_property  =  PropertyID : : BorderRightColor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        style_property  =  PropertyID : : BorderRightStyle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        width_property  =  PropertyID : : BorderRightWidth ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderTop : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        color_property  =  PropertyID : : BorderTopColor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        style_property  =  PropertyID : : BorderTopStyle ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        width_property  =  PropertyID : : BorderTopWidth ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  remaining_longhands  =  Vector  {  width_property ,  color_property ,  style_property  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  property_and_value  =  parse_css_value_for_properties ( remaining_longhands ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_and_value . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  value  =  property_and_value - > style_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remove_property ( remaining_longhands ,  property_and_value - > property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( property_and_value - > property  = =  width_property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! border_width ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            border_width  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( property_and_value - > property  = =  color_property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! border_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            border_color  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( property_and_value - > property  = =  style_property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! border_style ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            border_style  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:41:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! border_width ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        border_width  =  property_initial_value ( m_context . realm ( ) ,  width_property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! border_style ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        border_style  =  property_initial_value ( m_context . realm ( ) ,  style_property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! border_color ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        border_color  =  property_initial_value ( m_context . realm ( ) ,  color_property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( property_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  width_property ,  style_property ,  color_property  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  border_width . release_nonnull ( ) ,  border_style . release_nonnull ( ) ,  border_color . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_border_radius_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  2 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 20:49:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  horizontal  =  parse_dimension ( component_values [ 0 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  vertical  =  parse_dimension ( component_values [ 1 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( horizontal . has_value ( )  & &  horizontal - > is_length_percentage ( )  & &  vertical . has_value ( )  & &  vertical - > is_length_percentage ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  BorderRadiusStyleValue : : create ( horizontal - > length_percentage ( ) ,  vertical - > length_percentage ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-01-14 20:49:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  radius  =  parse_dimension ( component_values [ 0 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( radius . has_value ( )  & &  radius - > is_length_percentage ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  BorderRadiusStyleValue : : create ( radius - > length_percentage ( ) ,  radius - > length_percentage ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_border_radius_shorthand_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-02-07 17:05:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  top_left  =  [ & ] ( Vector < LengthPercentage > &  radii )  {  return  radii [ 0 ] ;  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  top_right  =  [ & ] ( Vector < LengthPercentage > &  radii )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( radii . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  4 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  3 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  2 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  radii [ 1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  1 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  radii [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-07 17:05:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  bottom_right  =  [ & ] ( Vector < LengthPercentage > &  radii )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( radii . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  4 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  3 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  radii [ 2 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  2 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  1 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  radii [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-07 17:05:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  bottom_left  =  [ & ] ( Vector < LengthPercentage > &  radii )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( radii . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  4 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  radii [ 3 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  3 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  2 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  radii [ 1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  1 : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  radii [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-07 17:05:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < LengthPercentage >  horizontal_radii ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < LengthPercentage >  vertical_radii ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  reading_vertical  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  value  :  component_values )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . is_delim ( ' / ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( reading_vertical  | |  horizontal_radii . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            reading_vertical  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-07 17:05:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_dimension  =  parse_dimension ( value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_dimension . has_value ( )  | |  ! maybe_dimension - > is_length_percentage ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( reading_vertical )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-07 17:05:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            vertical_radii . append ( maybe_dimension - > length_percentage ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-07 17:05:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            horizontal_radii . append ( maybe_dimension - > length_percentage ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( horizontal_radii . size ( )  >  4  | |  vertical_radii . size ( )  >  4 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        | |  horizontal_radii . is_empty ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        | |  ( reading_vertical  & &  vertical_radii . is_empty ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  top_left_radius  =  BorderRadiusStyleValue : : create ( top_left ( horizontal_radii ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        vertical_radii . is_empty ( )  ?  top_left ( horizontal_radii )  :  top_left ( vertical_radii ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  top_right_radius  =  BorderRadiusStyleValue : : create ( top_right ( horizontal_radii ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        vertical_radii . is_empty ( )  ?  top_right ( horizontal_radii )  :  top_right ( vertical_radii ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  bottom_right_radius  =  BorderRadiusStyleValue : : create ( bottom_right ( horizontal_radii ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        vertical_radii . is_empty ( )  ?  bottom_right ( horizontal_radii )  :  bottom_right ( vertical_radii ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  bottom_left_radius  =  BorderRadiusStyleValue : : create ( bottom_left ( horizontal_radii ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        vertical_radii . is_empty ( )  ?  bottom_left ( horizontal_radii )  :  bottom_left ( vertical_radii ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-18 17:10:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:01:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : BorderRadius , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : BorderTopLeftRadius ,  PropertyID : : BorderTopRightRadius ,  PropertyID : : BorderBottomRightRadius ,  PropertyID : : BorderBottomLeftRadius  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  move ( top_left_radius ) ,  move ( top_right_radius ) ,  move ( bottom_right_radius ) ,  move ( bottom_left_radius )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_shadow_value ( Vector < ComponentValue >  const &  component_values ,  AllowInsetKeyword  allow_inset_keyword )  
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-10-15 19:25:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // "none"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1  & &  component_values . first ( ) . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  parse_identifier_value ( component_values . first ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 19:25:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident  & &  ident - > to_identifier ( )  = =  ValueID : : None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  ident ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 16:59:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  parse_comma_separated_value_list ( component_values ,  [ this ,  allow_inset_keyword ] ( auto &  tokens )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  parse_single_shadow_value ( tokens ,  allow_inset_keyword ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_single_shadow_value ( TokenStream < ComponentValue > &  tokens ,  AllowInsetKeyword  allow_inset_keyword )  
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < Color >  color ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  offset_x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  offset_y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  blur_radius ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  spread_distance ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 16:55:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < ShadowPlacement >  placement ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  possibly_dynamic_length  =  [ & ] ( ComponentValue  const &  token )  - >  RefPtr < StyleValue >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  calculated_value  =  parse_calculated_value ( token ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! calculated_value - > resolves_to_length ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  calculated_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_length  =  parse_length ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_length . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  LengthStyleValue : : create ( maybe_length . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_color  =  parse_color ( token ) ;  maybe_color . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( color . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            color  =  maybe_color . release_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_offset_x  =  possibly_dynamic_length ( token ) ;  maybe_offset_x )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // horizontal offset
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( offset_x ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            offset_x  =  maybe_offset_x ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // vertical offset
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_offset_y  =  possibly_dynamic_length ( tokens . peek_token ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_offset_y ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            offset_y  =  maybe_offset_y ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // blur radius (optional)
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_blur_radius  =  possibly_dynamic_length ( tokens . peek_token ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_blur_radius ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            blur_radius  =  maybe_blur_radius ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 13:47:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // spread distance (optional)
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 13:47:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_spread_distance  =  possibly_dynamic_length ( tokens . peek_token ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_spread_distance ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 13:47:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            spread_distance  =  maybe_spread_distance ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 13:47:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 16:59:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( allow_inset_keyword  = =  AllowInsetKeyword : : Yes 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            & &  token . is ( Token : : Type : : Ident )  & &  token . token ( ) . ident ( ) . equals_ignoring_ascii_case ( " inset " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 13:47:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( placement . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 16:55:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            placement  =  ShadowPlacement : : Inner ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 14:07:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Comma ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: If color is absent, default to `currentColor`
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! color . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        color  =  Color : : NamedColor : : Black ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // x/y offsets are required
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! offset_x  | |  ! offset_y ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Other lengths default to 0
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! blur_radius ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        blur_radius  =  LengthStyleValue : : create ( Length : : make_px ( 0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! spread_distance ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        spread_distance  =  LengthStyleValue : : create ( Length : : make_px ( 0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 13:47:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Placement is outer by default
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! placement . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 16:55:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        placement  =  ShadowPlacement : : Outer ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-08 12:41:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 17:08:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-31 16:07:06 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShadowStyleValue : : create ( color . release_value ( ) ,  offset_x . release_nonnull ( ) ,  offset_y . release_nonnull ( ) ,  blur_radius . release_nonnull ( ) ,  spread_distance . release_nonnull ( ) ,  placement . release_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_content_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: `content` accepts several kinds of function() type, which we don't handle in property_accepts_value() yet.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_single_value_identifier  =  [ ] ( ValueID  identifier )  - >  bool  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( identifier )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  ValueID : : Normal : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  identifier  =  parse_identifier_value ( component_values . first ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( is_single_value_identifier ( identifier - > to_identifier ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  identifier ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-20 00:41:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  content_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  alt_text_values ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  in_alt_text  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  next  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( next . is_delim ( ' / ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( in_alt_text  | |  content_values . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            in_alt_text  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:47:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  style_value  =  parse_css_value_for_property ( PropertyID : : Content ,  tokens ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( is_single_value_identifier ( style_value - > to_identifier ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( in_alt_text )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                alt_text_values . append ( style_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                content_values . append ( style_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( content_values . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( in_alt_text  & &  alt_text_values . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValueList >  alt_text ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! alt_text_values . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        alt_text  =  StyleValueList : : create ( move ( alt_text_values ) ,  StyleValueList : : Separator : : Space ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ContentStyleValue : : create ( StyleValueList : : create ( move ( content_values ) ,  StyleValueList : : Separator : : Space ) ,  move ( alt_text ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-display-3/#the-display-properties
  
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_display_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_single_component_display  =  [ & ] ( Vector < ComponentValue >  const &  component_values )  - >  Optional < Display >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:39:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  identifier_value  =  parse_identifier_value ( component_values . first ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  identifier  =  identifier_value - > to_identifier ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( identifier  = =  ValueID : : ListItem ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  Display : : from_short ( Display : : Short : : ListItem ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:39:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  display_outside  =  value_id_to_display_outside ( identifier ) ;  display_outside . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                switch  ( display_outside . value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayOutside : : Block : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Block ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayOutside : : Inline : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Inline ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayOutside : : RunIn : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : RunIn ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  display_inside  =  value_id_to_display_inside ( identifier ) ;  display_inside . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                switch  ( display_inside . value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayInside : : Flow : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Flow ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayInside : : FlowRoot : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : FlowRoot ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayInside : : Table : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Table ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayInside : : Flex : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Flex ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayInside : : Grid : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Grid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayInside : : Ruby : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Ruby ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-07 16:03:20 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayInside : : Math : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Math ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:39:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  display_internal  =  value_id_to_display_internal ( identifier ) ;  display_internal . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  Display  {  display_internal . value ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  display_box  =  value_id_to_display_box ( identifier ) ;  display_box . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                switch  ( display_box . value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayBox : : Contents : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : Contents ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayBox : : None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  display_legacy  =  value_id_to_display_legacy ( identifier ) ;  display_legacy . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                switch  ( display_legacy . value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayLegacy : : InlineBlock : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : InlineBlock ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayLegacy : : InlineTable : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : InlineTable ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayLegacy : : InlineFlex : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : InlineFlex ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  DisplayLegacy : : InlineGrid : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  Display : : from_short ( Display : : Short : : InlineGrid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  OptionalNone  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_multi_component_display  =  [ & ] ( Vector < ComponentValue >  const &  component_values )  - >  Optional < Display >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  list_item  =  Display : : ListItem : : No ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:39:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        Optional < DisplayInside >  inside ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Optional < DisplayOutside >  outside ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( size_t  i  =  0 ;  i  <  component_values . size ( ) ;  + + i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  value  =  parse_identifier_value ( component_values [ i ] ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  identifier  =  value - > to_identifier ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 16:37:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( identifier  = =  ValueID : : ListItem )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( list_item  = =  Display : : ListItem : : Yes ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    list_item  =  Display : : ListItem : : Yes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:39:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  inside_value  =  value_id_to_display_inside ( identifier ) ;  inside_value . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 16:37:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( inside . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    inside  =  inside_value . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:39:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  outside_value  =  value_id_to_display_outside ( identifier ) ;  outside_value . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 16:37:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( outside . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    outside  =  outside_value . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 16:37:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 16:37:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Not a display value, abort.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " Unrecognized display value: `{}` " ,  component_values [ i ] . to_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // The spec does not allow any other inside values to be combined with list-item
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <display-outside>? && [ flow | flow-root ]? && list-item
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:39:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( list_item  = =  Display : : ListItem : : Yes  & &  inside . has_value ( )  & &  inside  ! =  DisplayInside : : Flow  & &  inside  ! =  DisplayInside : : FlowRoot ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 16:37:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 17:39:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  Display  {  outside . value_or ( DisplayOutside : : Block ) ,  inside . value_or ( DisplayInside : : Flow ) ,  list_item  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < Display >  display ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        display  =  parse_single_component_display ( component_values ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        display  =  parse_multi_component_display ( component_values ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( display . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  DisplayStyleValue : : create ( display . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_filter_value_list_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1  & &  component_values . first ( ) . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  parse_identifier_value ( component_values . first ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident  & &  ident - > to_identifier ( )  = =  ValueID : : None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  ident ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  tokens  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: <url>s are ignored for now
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <filter-value-list> = [ <filter-function> | <url> ]+
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    enum  class  FilterToken  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Color filters:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Brightness , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Contrast , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Grayscale , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Invert , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Opacity , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Saturate , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Sepia , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Special filters:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Blur , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        DropShadow , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        HueRotate 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  filter_token_to_operation  =  [ & ] ( auto  filter )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( to_underlying ( filter )  <  to_underlying ( FilterToken : : Blur ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  static_cast < Filter : : Color : : Operation > ( filter ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_number_percentage  =  [ & ] ( auto &  token )  - >  Optional < NumberPercentage >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Percentage ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  NumberPercentage ( Percentage ( token . token ( ) . percentage ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Number ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  NumberPercentage ( Number ( Number : : Type : : Number ,  token . token ( ) . number_value ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_filter_function_name  =  [ & ] ( auto  name )  - >  Optional < FilterToken >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " blur " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : Blur ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " brightness " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : Brightness ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " contrast " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : Contrast ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " drop-shadow " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : DropShadow ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " grayscale " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : Grayscale ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " hue-rotate " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : HueRotate ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " invert " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : Invert ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " opacity " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : Opacity ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " saturate " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : Saturate ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . equals_ignoring_ascii_case ( " sepia " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  FilterToken : : Sepia ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_filter_function  =  [ & ] ( auto  filter_token ,  auto  function_values )  - >  Optional < FilterFunction >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        TokenStream  tokens  {  function_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  if_no_more_tokens_return  =  [ & ] ( auto  filter )  - >  Optional < FilterFunction >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  filter ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( filter_token  = =  FilterToken : : Blur )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // blur( <length>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  Filter : : Blur  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  blur_radius  =  parse_length ( tokens . next_token ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! blur_radius . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  if_no_more_tokens_return ( Filter : : Blur  {  * blur_radius  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( filter_token  = =  FilterToken : : DropShadow )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-07 22:44:33 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  next_token  =  [ & ] ( )  - >  auto &  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  token ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // drop-shadow( [ <color>? && <length>{2,3} ] )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Note: The following code is a little awkward to allow the color to be before or after the lengths.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  first_param  =  next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Optional < Length >  maybe_radius  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_color  =  parse_color ( first_param ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  x_offset  =  parse_length ( maybe_color . has_value ( )  ?  next_token ( )  :  first_param ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! x_offset . has_value ( )  | |  ! tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  y_offset  =  parse_length ( next_token ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! y_offset . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  token  =  next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                maybe_radius  =  parse_length ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! maybe_color . has_value ( )  & &  ( ! maybe_radius . has_value ( )  | |  tokens . has_next_token ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    maybe_color  =  parse_color ( ! maybe_radius . has_value ( )  ?  token  :  next_token ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( ! maybe_color . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( ! maybe_radius . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  if_no_more_tokens_return ( Filter : : DropShadow  {  * x_offset ,  * y_offset ,  maybe_radius ,  maybe_color  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( filter_token  = =  FilterToken : : HueRotate )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // hue-rotate( [ <angle> | <zero> ]? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  Filter : : HueRotate  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( token . is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // hue-rotate(0)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  number  =  token . token ( ) . number ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( number . is_integer ( )  & &  number . integer_value ( )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  if_no_more_tokens_return ( Filter : : HueRotate  {  Filter : : HueRotate : : Zero  { }  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! token . is ( Token : : Type : : Dimension ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-20 13:02:41 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  angle_value  =  token . token ( ) . dimension_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  angle_unit_name  =  token . token ( ) . dimension_unit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  angle_unit  =  Angle : : unit_from_name ( angle_unit_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! angle_unit . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Angle  angle  {  angle_value ,  angle_unit . release_value ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  if_no_more_tokens_return ( Filter : : HueRotate  {  angle  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Simple filters:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // brightness( <number-percentage>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // contrast( <number-percentage>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // grayscale( <number-percentage>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // invert( <number-percentage>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // opacity( <number-percentage>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // sepia( <number-percentage>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // saturate( <number-percentage>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  Filter : : Color  {  filter_token_to_operation ( filter_token )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  amount  =  parse_number_percentage ( tokens . next_token ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! amount . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  if_no_more_tokens_return ( Filter : : Color  {  filter_token_to_operation ( filter_token ) ,  * amount  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < FilterFunction >  filter_value_list  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! token . is_function ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  filter_token  =  parse_filter_function_name ( token . function ( ) . name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! filter_token . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  filter_function  =  parse_filter_function ( * filter_token ,  token . function ( ) . values ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! filter_function . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        filter_value_list . append ( * filter_function ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( filter_value_list . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  FilterValueListStyleValue : : create ( move ( filter_value_list ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_flex_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:26:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  make_flex_shorthand  =  [ & ] ( NonnullRefPtr < StyleValue >  flex_grow ,  NonnullRefPtr < StyleValue >  flex_shrink ,  NonnullRefPtr < StyleValue >  flex_basis )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( PropertyID : : Flex , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  PropertyID : : FlexGrow ,  PropertyID : : FlexShrink ,  PropertyID : : FlexBasis  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  move ( flex_grow ) ,  move ( flex_shrink ) ,  move ( flex_basis )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 10:08:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // One-value syntax: <flex-grow> | <flex-basis> | none
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  properties  =  Array  {  PropertyID : : FlexGrow ,  PropertyID : : FlexBasis ,  PropertyID : : Flex  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  property_and_value  =  parse_css_value_for_properties ( properties ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_and_value . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  value  =  property_and_value - > style_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( property_and_value - > property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FlexGrow :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 10:08:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // https://github.com/w3c/csswg-drafts/issues/5742
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  flex_basis  =  PercentageStyleValue : : create ( Percentage ( 0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  one  =  NumberStyleValue : : create ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:26:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  make_flex_shorthand ( * value ,  one ,  flex_basis ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FlexBasis :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  one  =  NumberStyleValue : : create ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:26:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  make_flex_shorthand ( one ,  one ,  * value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : Flex :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( value - > is_identifier ( )  & &  value - > to_identifier ( )  = =  ValueID : : None )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  zero  =  NumberStyleValue : : create ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:26:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  make_flex_shorthand ( zero ,  zero ,  IdentifierStyleValue : : create ( ValueID : : Auto ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 14:36:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 14:36:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-19 10:08:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  flex_grow ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  flex_shrink ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  flex_basis ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: FlexGrow has to be before FlexBasis. `0` is a valid FlexBasis, but only
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //       if FlexGrow (along with optional FlexShrink) have already been specified.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  remaining_longhands  =  Vector  {  PropertyID : : FlexGrow ,  PropertyID : : FlexBasis  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  property_and_value  =  parse_css_value_for_properties ( remaining_longhands ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_and_value . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  value  =  property_and_value - > style_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remove_property ( remaining_longhands ,  property_and_value - > property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( property_and_value - > property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FlexGrow :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! flex_grow ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            flex_grow  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Flex-shrink may optionally follow directly after.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_flex_shrink  =  parse_css_value_for_property ( PropertyID : : FlexShrink ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( maybe_flex_shrink ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                flex_shrink  =  maybe_flex_shrink . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FlexBasis :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! flex_basis ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            flex_basis  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 16:21:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! flex_grow ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        flex_grow  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : FlexGrow ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! flex_shrink ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        flex_shrink  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : FlexShrink ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 17:16:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! flex_basis )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // https://github.com/w3c/csswg-drafts/issues/5742
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        flex_basis  =  PercentageStyleValue : : create ( Percentage ( 0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 17:16:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:26:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  make_flex_shorthand ( flex_grow . release_nonnull ( ) ,  flex_shrink . release_nonnull ( ) ,  flex_basis . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_flex_flow_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  >  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  flex_direction ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  flex_wrap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 17:10:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  remaining_longhands  =  Vector  {  PropertyID : : FlexDirection ,  PropertyID : : FlexWrap  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  property_and_value  =  parse_css_value_for_properties ( remaining_longhands ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_and_value . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  value  =  property_and_value - > style_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remove_property ( remaining_longhands ,  property_and_value - > property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 17:10:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( property_and_value - > property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 17:10:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FlexDirection : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! flex_direction ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            flex_direction  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 17:10:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FlexWrap : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! flex_wrap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            flex_wrap  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-18 17:10:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! flex_direction ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        flex_direction  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : FlexDirection ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! flex_wrap ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        flex_wrap  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : FlexWrap ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 14:45:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : FlexFlow , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : FlexDirection ,  PropertyID : : FlexWrap  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  flex_direction . release_nonnull ( ) ,  flex_wrap . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  bool  is_generic_font_family ( ValueID  identifier )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    switch  ( identifier )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : Cursive : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : Fantasy : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : Monospace : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : Serif : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : SansSerif : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : UiMonospace : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : UiRounded : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : UiSerif : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  ValueID : : UiSansSerif : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_font_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-02-03 14:27:09 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  font_stretch ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  font_style ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  font_weight ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  font_size ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  line_height ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  font_families ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 14:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  font_variant ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Handle system fonts. (caption, icon, menu, message-box, small-caption, status-bar)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Several sub-properties can be "normal", and appear in any order: style, variant, weight, stretch
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // So, we have to handle that separately.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    int  normal_count  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  remaining_longhands  =  Vector  {  PropertyID : : FontSize ,  PropertyID : : FontStretch ,  PropertyID : : FontStyle ,  PropertyID : : FontVariant ,  PropertyID : : FontWeight  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  peek_token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( peek_token . is ( Token : : Type : : Ident )  & &  value_id_from_string ( peek_token . token ( ) . ident ( ) )  = =  ValueID : : Normal )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            normal_count + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  property_and_value  =  parse_css_value_for_properties ( remaining_longhands ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_and_value . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  value  =  property_and_value - > style_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remove_property ( remaining_longhands ,  property_and_value - > property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( property_and_value - > property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FontSize :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! font_size ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            font_size  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume `/ line-height` if present
 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( tokens . peek_token ( ) . is_delim ( ' / ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  maybe_line_height  =  parse_css_value_for_property ( PropertyID : : LineHeight ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! maybe_line_height ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_height  =  maybe_line_height . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Consume font-families
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_font_families  =  parse_font_family_value ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // font-family comes last, so we must not have any tokens left over.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_font_families  | |  tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            font_families  =  maybe_font_families . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FontStretch :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! font_stretch ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-03 14:27:09 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            font_stretch  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FontStyle :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Handle angle parameter to `oblique`: https://www.w3.org/TR/css-fonts-4/#font-style-prop
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! font_style ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            font_style  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FontVariant :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! font_variant ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            font_variant  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : FontWeight :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! font_weight ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            font_weight  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Since normal is the default value for all the properties that can have it, we don't have to actually
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:52:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // set anything to normal here. It'll be set when we create the ShorthandStyleValue below.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // We just need to make sure we were not given more normals than will fit.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-04 15:13:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    int  unset_value_count  =  ( font_style  ?  0  :  1 )  +  ( font_weight  ?  0  :  1 )  +  ( font_variant  ?  0  :  1 )  +  ( font_stretch  ?  0  :  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( unset_value_count  <  normal_count ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! font_size  | |  ! font_families ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! font_style ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        font_style  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : FontStyle ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:39:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! font_variant ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        font_variant  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : FontVariant ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! font_weight ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        font_weight  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : FontWeight ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:39:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! font_stretch ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        font_stretch  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : FontStretch ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! line_height ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        line_height  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : LineHeight ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:39:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : Font , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : FontStyle ,  PropertyID : : FontVariant ,  PropertyID : : FontWeight ,  PropertyID : : FontStretch ,  PropertyID : : FontSize ,  PropertyID : : LineHeight ,  PropertyID : : FontFamily  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  font_style . release_nonnull ( ) ,  font_variant . release_nonnull ( ) ,  font_weight . release_nonnull ( ) ,  font_stretch . release_nonnull ( ) ,  font_size . release_nonnull ( ) ,  line_height . release_nonnull ( ) ,  font_families . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_font_family_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  next_is_comma_or_eof  =  [ & ] ( )  - >  bool  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ! tokens . has_next_token ( )  | |  tokens . peek_token ( ) . is ( Token : : Type : : Comma ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Note: Font-family names can either be a quoted string, or a keyword, or a series of custom-idents.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // eg, these are equivalent:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     font-family: my cool     font\!, serif;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     font-family: "my cool font!", serif;
 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-20 00:41:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  font_families ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 18:02:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < DeprecatedString >  current_name_parts ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  peek  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( peek . is ( Token : : Type : : String ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // `font-family: my cool "font";` is invalid.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! current_name_parts . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ;  // String
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! next_is_comma_or_eof ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            font_families . append ( StringStyleValue : : create ( MUST ( String : : from_utf8 ( peek . token ( ) . string ( ) ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ;  // Comma
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( peek . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // If this is a valid identifier, it's NOT a custom-ident and can't be part of a larger name.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // CSS-wide keywords are not allowed
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  builtin  =  parse_builtin_value ( peek ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_ident  =  value_id_from_string ( peek . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Can't have a generic-font-name as a token in an unquoted font name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( maybe_ident . has_value ( )  & &  is_generic_font_family ( maybe_ident . value ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! current_name_parts . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                ( void ) tokens . next_token ( ) ;  // Ident
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! next_is_comma_or_eof ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                font_families . append ( IdentifierStyleValue : : create ( maybe_ident . value ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                ( void ) tokens . next_token ( ) ;  // Comma
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-07 00:22:33 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            current_name_parts . append ( tokens . next_token ( ) . token ( ) . ident ( ) . bytes_as_string_view ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( peek . is ( Token : : Type : : Comma ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( current_name_parts . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ;  // Comma
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-12 12:44:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // This is really a series of custom-idents, not just one. But for the sake of simplicity we'll make it one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            font_families . append ( CustomIdentStyleValue : : create ( MUST ( String : : join ( '   ' ,  current_name_parts ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            current_name_parts . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Can't have a trailing comma
 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:13:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! current_name_parts . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-12 12:44:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // This is really a series of custom-idents, not just one. But for the sake of simplicity we'll make it one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        font_families . append ( CustomIdentStyleValue : : create ( MUST ( String : : join ( '   ' ,  current_name_parts ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 17:01:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        current_name_parts . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( font_families . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  StyleValueList : : create ( move ( font_families ) ,  StyleValueList : : Separator : : Comma ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-07 15:46:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								CSSRule *  Parser : : parse_font_face_rule ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  declarations_and_at_rules  =  parse_a_list_of_declarations ( tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-18 15:13:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < FlyString >  font_family ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < FontFace : : Source >  src ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 16:39:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < UnicodeRange >  unicode_range ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 15:35:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < int >  weight ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < int >  slope ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  declaration_or_at_rule  :  declarations_and_at_rules )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( declaration_or_at_rule . is_at_rule ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 14:35:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: CSS at-rules are not allowed in @font-face; discarding. " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  declaration  =  declaration_or_at_rule . declaration ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 15:35:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( declaration . name ( ) . equals_ignoring_ascii_case ( " font-weight " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  token_stream  {  declaration . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  value  =  parse_css_value ( CSS : : PropertyID : : FontWeight ,  token_stream ) ;  ! value . is_error ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                weight  =  value . value ( ) - > to_font_weight ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( declaration . name ( ) . equals_ignoring_ascii_case ( " font-style " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  token_stream  {  declaration . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  value  =  parse_css_value ( CSS : : PropertyID : : FontStyle ,  token_stream ) ;  ! value . is_error ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                slope  =  value . value ( ) - > to_font_slope ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( declaration . name ( ) . equals_ignoring_ascii_case ( " font-family " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: This is very similar to, but different from, the logic in parse_font_family_value().
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //        Ideally they could share code.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-04 18:02:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < DeprecatedString >  font_family_parts ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            bool  had_syntax_error  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 14:41:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( size_t  i  =  0 ;  i  <  declaration . values ( ) . size ( ) ;  + + i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  const &  part  =  declaration . values ( ) [ i ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( part . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( part . is ( Token : : Type : : String ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( ! font_family_parts . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face font-family format invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        had_syntax_error  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    font_family_parts . append ( part . token ( ) . string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( part . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 14:39:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( is_css_wide_keyword ( part . token ( ) . ident ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 20:14:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face font-family format invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        had_syntax_error  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  value_id  =  value_id_from_string ( part . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 12:43:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( value_id . has_value ( )  & &  is_generic_font_family ( value_id . value ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face font-family format invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        had_syntax_error  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-07 00:22:33 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    font_family_parts . append ( part . token ( ) . ident ( ) . bytes_as_string_view ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face font-family format invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                had_syntax_error  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( had_syntax_error  | |  font_family_parts . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-18 15:13:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            font_family  =  String : : join ( '   ' ,  font_family_parts ) . release_value_but_fixme_should_propagate_errors ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( declaration . name ( ) . equals_ignoring_ascii_case ( " src " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 14:41:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  token_stream  {  declaration . values ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < FontFace : : Source >  supported_sources  =  parse_font_face_src ( token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! supported_sources . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                src  =  move ( supported_sources ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 16:39:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( declaration . name ( ) . equals_ignoring_ascii_case ( " unicode-range " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 16:39:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < UnicodeRange >  unicode_ranges ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            bool  unicode_range_invalid  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  all_tokens  {  declaration . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  range_token_lists  =  parse_a_comma_separated_list_of_component_values ( all_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( auto &  range_tokens  :  range_token_lists )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                TokenStream  range_token_stream  {  range_tokens  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  maybe_unicode_range  =  parse_unicode_range ( range_token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! maybe_unicode_range . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face unicode-range format invalid; discarding. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    unicode_range_invalid  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                unicode_ranges . append ( maybe_unicode_range . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( unicode_range_invalid  | |  unicode_ranges . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            unicode_range  =  move ( unicode_ranges ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 14:35:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: Unrecognized descriptor '{}' in @font-face; discarding. " ,  declaration . name ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! font_family . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: Failed to parse @font-face: no font-family! " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 16:39:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( unicode_range . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        unicode_range . empend ( 0x0u ,  0x10FFFFu ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-13 13:05:26 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  CSSFontFaceRule : : create ( m_context . realm ( ) ,  FontFace  {  font_family . release_value ( ) ,  weight ,  slope ,  move ( src ) ,  move ( unicode_range )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 20:32:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Vector < FontFace : : Source >  Parser : : parse_font_face_src ( TokenStream < ComponentValue > &  component_values )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Get this information from the system somehow?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Format-name table: https://www.w3.org/TR/css-fonts-4/#font-format-definitions
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  font_format_is_supported  =  [ ] ( StringView  name )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // The spec requires us to treat opentype and truetype as synonymous.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-12 11:59:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( name . is_one_of_ignoring_ascii_case ( " opentype " sv ,  " truetype " sv ,  " woff " sv ,  " woff2 " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < FontFace : : Source >  supported_sources ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  list_of_source_token_lists  =  parse_a_comma_separated_list_of_component_values ( component_values ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  source_token_list  :  list_of_source_token_lists )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        TokenStream  source_tokens  {  source_token_list  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        source_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  first  =  source_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // <url> [ format(<font-format>)]?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Implement optional tech() function from CSS-Fonts-4.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 15:29:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_url  =  parse_url_function ( first ) ;  maybe_url . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  url  =  maybe_url . release_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
											
												LibWeb: Load alternative font urls if others fail
We don't support all parts of the font formats we assume as "supported"
in the CSS parser. For example, if an open type font has a CFF table, we
reject loading it. This meant that until now, when such an
unsupported-supported font url was first in the list of urls, we
couldn't load it at all, even when we would support a later url.
To resolve that, try loading all font urls one after each other, in case
we are not able to load the higher priority one.
This also resolves a FIXME related to spec compliant url prioritization.
Our CSS parser already filters and prioritizes font src urls in
compliance with the spec. However, we still had to resort to brittle
file extension matching, because some websites don't set the `format`
and if the first url in a src list happened to be one we don't support,
the font could not be loaded at all. This now is unnecessary because we
can try and discard the urls instead.
											 
										 
										
											2023-03-18 12:44:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! url . is_valid ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-18 15:13:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Optional < FlyString >  format ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            source_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! source_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                supported_sources . empend ( move ( url ) ,  format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_function  =  source_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_function . is_function ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face src invalid (token after `url()` that isn't a function: {}); discarding. " ,  maybe_function . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  function  =  maybe_function . function ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( function . name ( ) . equals_ignoring_ascii_case ( " format " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                TokenStream  format_tokens  {  function . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                format_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  const &  format_name_token  =  format_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                StringView  format_name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( format_name_token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    format_name  =  format_name_token . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( format_name_token . is ( Token : : Type : : String ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    format_name  =  format_name_token . token ( ) . string ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face src invalid (`format()` parameter not an ident or string; is: {}); discarding. " ,  format_name_token . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! font_format_is_supported ( format_name ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face src format({}) not supported; skipping. " ,  format_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-18 15:13:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                format  =  FlyString : : from_utf8 ( format_name ) . release_value_but_fixme_should_propagate_errors ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face src invalid (unrecognized function token `{}`); discarding. " ,  function . name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            source_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( source_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face src invalid (extra token `{}`); discarding. " ,  source_tokens . peek_token ( ) . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            supported_sources . empend ( move ( url ) ,  format ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 10:52:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( first . is_function ( )  & &  first . function ( ) . name ( ) . equals_ignoring_ascii_case ( " local " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( first . function ( ) . values ( ) . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            supported_sources . empend ( first . function ( ) . values ( ) . first ( ) . to_string ( ) ,  Optional < FlyString >  { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " CSSParser: @font-face src invalid (failed to parse url from: {}); discarding. " ,  first . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 21:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  supported_sources ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_list_style_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  >  3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  list_position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  list_image ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  list_type ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    int  found_nones  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:09:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < PropertyID >  remaining_longhands  {  PropertyID : : ListStyleImage ,  PropertyID : : ListStylePosition ,  PropertyID : : ListStyleType  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:09:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  peek  =  tokens . peek_token ( ) ;  peek . is ( Token : : Type : : Ident )  & &  peek . token ( ) . ident ( ) . equals_ignoring_ascii_case ( " none " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            found_nones + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  property_and_value  =  parse_css_value_for_properties ( remaining_longhands ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_and_value . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:09:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  value  =  property_and_value - > style_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remove_property ( remaining_longhands ,  property_and_value - > property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:09:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( property_and_value - > property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:09:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : ListStylePosition :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! list_position ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            list_position  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:09:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : ListStyleImage :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! list_image ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            list_image  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:09:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : ListStyleType :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! list_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            list_type  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:09:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( found_nones  >  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( found_nones  = =  2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( list_image  | |  list_type ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  none  =  IdentifierStyleValue : : create ( ValueID : : None ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        list_image  =  none ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        list_type  =  none ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( found_nones  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( list_image  & &  list_type ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  none  =  IdentifierStyleValue : : create ( ValueID : : None ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! list_image ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            list_image  =  none ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! list_type ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            list_type  =  none ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! list_position ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        list_position  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : ListStylePosition ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! list_image ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        list_image  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : ListStyleImage ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! list_type ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        list_type  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : ListStyleType ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 14:58:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : ListStyle , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : ListStylePosition ,  PropertyID : : ListStyleImage ,  PropertyID : : ListStyleType  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  list_position . release_nonnull ( ) ,  list_image . release_nonnull ( ) ,  list_type . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-07 15:29:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_math_depth_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://w3c.github.io/mathml-core/#propdef-math-depth
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // auto-add | add(<integer>) | <integer>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // auto-add
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is_ident ( " auto-add " sv ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  MathDepthStyleValue : : create_auto_add ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Make it easier to parse "thing that might be <bar> or literally anything that resolves to it" and get rid of this
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_something_that_resolves_to_integer  =  [ this ] ( ComponentValue &  token )  - >  RefPtr < StyleValue >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Number )  & &  token . token ( ) . number ( ) . is_integer ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  IntegerStyleValue : : create ( token . token ( ) . to_integer ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  value  =  parse_calculated_value ( token ) ;  value  & &  value - > resolves_to_number ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // add(<integer>)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is_function ( " add " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  add_tokens  =  TokenStream  {  token . function ( ) . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        add_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  integer_token  =  add_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        add_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( add_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  integer_value  =  parse_something_that_resolves_to_integer ( integer_token ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  MathDepthStyleValue : : create_add ( integer_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <integer>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  integer_value  =  parse_something_that_resolves_to_integer ( token ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  MathDepthStyleValue : : create_integer ( integer_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_overflow_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:54:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:15:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:54:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_value  =  parse_css_value_for_property ( PropertyID : : Overflow ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:54:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:32:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( PropertyID : : Overflow , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  PropertyID : : OverflowX ,  PropertyID : : OverflowY  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  * maybe_value ,  * maybe_value  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:54:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  2 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_x_value  =  parse_css_value_for_property ( PropertyID : : OverflowX ,  tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_y_value  =  parse_css_value_for_property ( PropertyID : : OverflowY ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:54:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_x_value  | |  ! maybe_y_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:32:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( PropertyID : : Overflow , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  PropertyID : : OverflowX ,  PropertyID : : OverflowY  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  maybe_x_value . release_nonnull ( ) ,  maybe_y_value . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:54:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_place_content_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-05-29 16:34:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  >  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_align_content_value  =  parse_css_value_for_property ( PropertyID : : AlignContent ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-29 16:34:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_align_content_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_accepts_identifier ( PropertyID : : JustifyContent ,  maybe_align_content_value - > to_identifier ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 15:06:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( PropertyID : : PlaceContent , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  PropertyID : : AlignContent ,  PropertyID : : JustifyContent  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  * maybe_align_content_value ,  * maybe_align_content_value  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-29 16:34:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_justify_content_value  =  parse_css_value_for_property ( PropertyID : : JustifyContent ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-29 16:34:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_justify_content_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 15:06:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : PlaceContent , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : AlignContent ,  PropertyID : : JustifyContent  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  maybe_align_content_value . release_nonnull ( ) ,  maybe_justify_content_value . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-29 16:34:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_place_items_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-07-17 16:34:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_align_items_value  =  parse_css_value_for_property ( PropertyID : : AlignItems ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-17 16:34:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_align_items_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_accepts_identifier ( PropertyID : : JustifyItems ,  maybe_align_items_value - > to_identifier ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 15:30:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( PropertyID : : PlaceItems , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  PropertyID : : AlignItems ,  PropertyID : : JustifyItems  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  * maybe_align_items_value ,  * maybe_align_items_value  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-17 16:34:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_justify_items_value  =  parse_css_value_for_property ( PropertyID : : JustifyItems ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-17 16:34:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_justify_items_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 15:30:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : PlaceItems , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : AlignItems ,  PropertyID : : JustifyItems  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  * maybe_align_items_value ,  * maybe_justify_items_value  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-17 16:34:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_place_self_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-08-04 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_align_self_value  =  parse_css_value_for_property ( PropertyID : : AlignSelf ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_align_self_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_accepts_identifier ( PropertyID : : JustifySelf ,  maybe_align_self_value - > to_identifier ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 15:20:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( PropertyID : : PlaceSelf , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  PropertyID : : AlignSelf ,  PropertyID : : JustifySelf  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  * maybe_align_self_value ,  * maybe_align_self_value  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_justify_self_value  =  parse_css_value_for_property ( PropertyID : : JustifySelf ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_justify_self_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 15:20:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : PlaceSelf , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : AlignSelf ,  PropertyID : : JustifySelf  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  * maybe_align_self_value ,  * maybe_justify_self_value  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-12 11:34:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_quotes_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://www.w3.org/TR/css-content-3/#quotes-property
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // auto | none | [ <string> <string> ]+
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  identifier  =  parse_identifier_value ( component_values . first ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( identifier  & &  property_accepts_identifier ( PropertyID : : Quotes ,  identifier - > to_identifier ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  identifier ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Parse an even number of <string> values.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  %  2  ! =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  string_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_string  =  parse_string_value ( tokens . next_token ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_string ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        string_values . append ( maybe_string . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  StyleValueList : : create ( move ( string_values ) ,  StyleValueList : : Separator : : Space ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_text_decoration_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  decoration_line ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 02:09:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  decoration_thickness ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  decoration_style ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    RefPtr < StyleValue >  decoration_color ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  remaining_longhands  =  Vector  {  PropertyID : : TextDecorationColor ,  PropertyID : : TextDecorationLine ,  PropertyID : : TextDecorationStyle ,  PropertyID : : TextDecorationThickness  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  property_and_value  =  parse_css_value_for_properties ( remaining_longhands ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! property_and_value . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  value  =  property_and_value - > style_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        remove_property ( remaining_longhands ,  property_and_value - > property ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( property_and_value - > property )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : TextDecorationColor :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! decoration_color ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            decoration_color  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : TextDecorationLine :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! decoration_line ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  parsed_decoration_line  =  parse_text_decoration_line_value ( tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! parsed_decoration_line ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            decoration_line  =  parsed_decoration_line . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : TextDecorationThickness :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! decoration_thickness ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 02:09:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            decoration_thickness  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  PropertyID : : TextDecorationStyle :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( ! decoration_style ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            decoration_style  =  value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! decoration_line ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        decoration_line  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : TextDecorationLine ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-06 02:09:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! decoration_thickness ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        decoration_thickness  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : TextDecorationThickness ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! decoration_style ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        decoration_style  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : TextDecorationStyle ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! decoration_color ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        decoration_color  =  property_initial_value ( m_context . realm ( ) ,  PropertyID : : TextDecorationColor ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 15:52:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : TextDecoration , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : TextDecorationLine ,  PropertyID : : TextDecorationThickness ,  PropertyID : : TextDecorationStyle ,  PropertyID : : TextDecorationColor  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  decoration_line . release_nonnull ( ) ,  decoration_thickness . release_nonnull ( ) ,  decoration_style . release_nonnull ( ) ,  decoration_color . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_text_decoration_line_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-02-20 00:41:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  style_values ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_value  =  parse_css_value_for_property ( PropertyID : : TextDecorationLine ,  tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:24:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_value ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  value  =  maybe_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_line  =  value_id_to_text_decoration_line ( value - > to_identifier ( ) ) ;  maybe_line . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:24:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( maybe_line  = =  TextDecorationLine : : None )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! style_values . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:24:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( style_values . contains_slow ( value ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            style_values . append ( move ( value ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( style_values . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  StyleValueList : : create ( move ( style_values ) ,  StyleValueList : : Separator : : Space ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_easing_value ( TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2023-07-06 02:29:36 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  const &  part  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StringView  name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < Vector < ComponentValue >  const & >  arguments ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( part . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        name  =  part . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( part . is_function ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        name  =  part . function ( ) . name ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        arguments  =  part . function ( ) . values ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  maybe_function  =  easing_function_from_string ( name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! maybe_function . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  function  =  maybe_function . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  function_metadata  =  easing_function_metadata ( function ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( function_metadata . parameters . is_empty ( )  & &  arguments . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " Too many arguments to {}. max: 0 " ,  name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    size_t  argument_index  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( arguments . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  argument_tokens  =  TokenStream  {  * arguments  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  arguments_values  =  parse_a_comma_separated_list_of_component_values ( argument_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( arguments_values . size ( )  >  function_metadata . parameters . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " Too many arguments to {}. max: {} " ,  name ,  function_metadata . parameters . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto &  argument_values  :  arguments_values )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-25 06:32:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Prune any whitespace before and after the actual argument values.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            argument_values . remove_all_matching ( [ ] ( auto &  value )  {  return  value . is ( Token : : Type : : Whitespace ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 02:29:36 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( argument_values . size ( )  ! =  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " Too many values in argument to {}. max: 1 " ,  name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  value  =  argument_values [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            switch  ( function_metadata . parameters [ argument_index ] . type )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  EasingFunctionParameterType : : Number :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( value . is ( Token : : Type : : Number ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( NumberStyleValue : : create ( value . token ( ) . number ( ) . value ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 02:29:36 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  EasingFunctionParameterType : : NumberZeroToOne :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( value . is ( Token : : Type : : Number )  & &  value . token ( ) . number_value ( )  > =  0  & &  value . token ( ) . number_value ( )  < =  1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( NumberStyleValue : : create ( value . token ( ) . number ( ) . value ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 02:29:36 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  EasingFunctionParameterType : : Integer :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( value . is ( Token : : Type : : Number )  & &  value . token ( ) . number ( ) . is_integer ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( IntegerStyleValue : : create ( value . token ( ) . number ( ) . integer_value ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 02:29:36 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  EasingFunctionParameterType : : StepPosition :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! value . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  ident  =  parse_identifier_value ( value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 02:29:36 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! ident ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                switch  ( ident - > to_identifier ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  ValueID : : JumpStart : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  ValueID : : JumpEnd : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  ValueID : : JumpNone : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  ValueID : : Start : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                case  ValueID : : End : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( * ident ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 02:29:36 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            + + argument_index ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( argument_index  <  function_metadata . parameters . size ( )  & &  ! function_metadata . parameters [ argument_index ] . is_optional )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " Required parameter at position {} is missing " ,  argument_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  EasingStyleValue : : create ( function ,  move ( values ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_transform_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-02-20 00:41:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  transformations ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 19:33:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  part  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( part . is ( Token : : Type : : Ident )  & &  part . token ( ) . ident ( ) . equals_ignoring_ascii_case ( " none " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-10 13:47:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! transformations . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 19:33:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  IdentifierStyleValue : : create ( ValueID : : None ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-10 13:47:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! part . is_function ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 15:52:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  maybe_function  =  transform_function_from_string ( part . function ( ) . name ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! maybe_function . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  function  =  maybe_function . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  function_metadata  =  transform_function_metadata ( function ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-02-20 00:41:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        StyleValueVector  values ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 19:49:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  argument_tokens  =  TokenStream  {  part . function ( ) . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        argument_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-26 16:09:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        size_t  argument_index  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 19:49:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        while  ( argument_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-26 16:09:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( argument_index  = =  function_metadata . parameters . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dbgln_if ( CSS_PARSER_DEBUG ,  " Too many arguments to {}. max: {} " ,  part . function ( ) . name ( ) ,  function_metadata . parameters . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  value  =  argument_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            RefPtr < CalculatedStyleValue >  maybe_calc_value  =  parse_calculated_value ( value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-26 16:09:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            switch  ( function_metadata . parameters [ argument_index ] . type )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            case  TransformFunctionParameterType : : Angle :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // These are `<angle> | <zero>` in the spec, so we have to check for both kinds.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( maybe_calc_value  & &  maybe_calc_value - > resolves_to_angle ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:33:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( maybe_calc_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( value . is ( Token : : Type : : Number )  & &  value . token ( ) . number_value ( )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( AngleStyleValue : : create ( Angle : : make_degrees ( 0 ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  dimension_value  =  parse_dimension_value ( value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( ! dimension_value  | |  ! dimension_value - > is_angle ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( dimension_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 02:46:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  TransformFunctionParameterType : : Length :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( maybe_calc_value  & &  maybe_calc_value - > resolves_to_length ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:46:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( maybe_calc_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 02:46:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  dimension_value  =  parse_dimension_value ( value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 02:46:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( ! dimension_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( dimension_value - > is_length ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        values . append ( dimension_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  TransformFunctionParameterType : : LengthPercentage :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( maybe_calc_value  & &  maybe_calc_value - > resolves_to_length ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:46:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( maybe_calc_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  dimension_value  =  parse_dimension_value ( value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( ! dimension_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( dimension_value - > is_percentage ( )  | |  dimension_value - > is_length ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        values . append ( dimension_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  TransformFunctionParameterType : : Number :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( maybe_calc_value  & &  maybe_calc_value - > resolves_to_number ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-30 15:46:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( maybe_calc_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    // FIXME: Remove this reconsume once all parsing functions are TokenStream-based.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    argument_tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  number  =  parse_number_value ( argument_tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-20 13:49:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( ! number ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    values . append ( number . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-17 16:53:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 19:49:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            argument_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( argument_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // Arguments must be separated by commas.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! argument_tokens . next_token ( ) . is ( Token : : Type : : Comma ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                argument_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // If there are no more parameters after the comma, this is invalid.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! argument_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-26 16:09:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            argument_index + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-26 16:09:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( argument_index  <  function_metadata . parameters . size ( )  & &  function_metadata . parameters [ argument_index ] . required )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln_if ( CSS_PARSER_DEBUG ,  " Required parameter at position {} is missing " ,  argument_index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-17 17:37:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        transformations . append ( TransformationStyleValue : : create ( function ,  move ( values ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  StyleValueList : : create ( move ( transformations ) ,  StyleValueList : : Separator : : Space ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-transforms-1/#propdef-transform-origin
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// FIXME: This only supports a 2D position
  
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_transform_origin_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    enum  class  Axis  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        None , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        X , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Y , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    struct  AxisOffset  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Axis  axis ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        NonnullRefPtr < StyleValue >  offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  to_axis_offset  =  [ ] ( RefPtr < StyleValue >  value )  - >  Optional < AxisOffset >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-29 07:58:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  OptionalNone  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value - > is_percentage ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  AxisOffset  {  Axis : : None ,  value - > as_percentage ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value - > is_length ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  AxisOffset  {  Axis : : None ,  value - > as_length ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value - > is_identifier ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            switch  ( value - > to_identifier ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            case  ValueID : : Top : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  AxisOffset  {  Axis : : Y ,  PercentageStyleValue : : create ( Percentage ( 0 ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            case  ValueID : : Left : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  AxisOffset  {  Axis : : X ,  PercentageStyleValue : : create ( Percentage ( 0 ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            case  ValueID : : Center : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  AxisOffset  {  Axis : : None ,  PercentageStyleValue : : create ( Percentage ( 50 ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            case  ValueID : : Bottom : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  AxisOffset  {  Axis : : Y ,  PercentageStyleValue : : create ( Percentage ( 100 ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            case  ValueID : : Right : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  AxisOffset  {  Axis : : X ,  PercentageStyleValue : : create ( Percentage ( 100 ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            default : 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  OptionalNone  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  OptionalNone  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  make_list  =  [ ] ( NonnullRefPtr < StyleValue >  const &  x_value ,  NonnullRefPtr < StyleValue >  const &  y_value )  - >  NonnullRefPtr < StyleValueList >  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-02-20 00:41:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        StyleValueVector  values ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        values . append ( x_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        values . append ( y_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  StyleValueList : : create ( move ( values ) ,  StyleValueList : : Separator : : Space ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 17:44:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    switch  ( component_values . size ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  1 :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  single_value  =  to_axis_offset ( parse_css_value_for_property ( PropertyID : : TransformOrigin ,  tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! single_value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // If only one value is specified, the second value is assumed to be center.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: If one or two values are specified, the third value is assumed to be 0px.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        switch  ( single_value - > axis )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  Axis : : None : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        case  Axis : : X : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  make_list ( single_value - > offset ,  PercentageStyleValue : : create ( Percentage ( 50 ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        case  Axis : : Y : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  make_list ( PercentageStyleValue : : create ( Percentage ( 50 ) ) ,  single_value - > offset ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  2 :  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  first_value  =  to_axis_offset ( parse_css_value_for_property ( PropertyID : : TransformOrigin ,  tokens ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  second_value  =  to_axis_offset ( parse_css_value_for_property ( PropertyID : : TransformOrigin ,  tokens ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! first_value . has_value ( )  | |  ! second_value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        RefPtr < StyleValue >  x_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        RefPtr < StyleValue >  y_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( first_value - > axis  = =  Axis : : X )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            x_value  =  first_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( first_value - > axis  = =  Axis : : Y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            y_value  =  first_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( second_value - > axis  = =  Axis : : X )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( x_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            x_value  =  second_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Put the other in Y since its axis can't have been X
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            y_value  =  first_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( second_value - > axis  = =  Axis : : Y )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( y_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            y_value  =  second_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Put the other in X since its axis can't have been Y
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            x_value  =  first_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( x_value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY ( ! y_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                y_value  =  second_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY ( ! x_value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                x_value  =  second_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // If two or more values are defined and either no value is a keyword, or the only used keyword is center,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // then the first value represents the horizontal position (or offset) and the second represents the vertical position (or offset).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: A third value always represents the Z position (or offset) and must be of type <length>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( first_value - > axis  = =  Axis : : None  & &  second_value - > axis  = =  Axis : : None )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            x_value  =  first_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            y_value  =  second_value - > offset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  make_list ( x_value . release_nonnull ( ) ,  y_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_as_css_value ( PropertyID  property_id )  
						 
					
						
							
								
									
										
										
										
											2021-07-30 17:48:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-30 12:39:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  component_values  =  parse_a_list_of_component_values ( m_token_stream ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-30 17:48:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream ( component_values ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parsed_value  =  parse_css_value ( property_id ,  tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( parsed_value . is_error ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  parsed_value . release_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-30 17:48:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < CSS : : GridSize >  Parser : : parse_grid_size ( ComponentValue  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-05-10 23:46:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_value . is_function ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 15:23:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_calculated  =  parse_calculated_value ( component_value ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( maybe_calculated - > resolves_to_length_percentage ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  GridSize ( LengthPercentage ( maybe_calculated . release_nonnull ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Support calculated <flex>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-21 03:07:28 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-15 12:58:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-10 23:46:33 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  token  =  component_value . token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is ( Token : : Type : : Ident )  & &  token . ident ( ) . equals_ignoring_ascii_case ( " auto " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  GridSize : : make_auto ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is ( Token : : Type : : Ident )  & &  token . ident ( ) . equals_ignoring_ascii_case ( " max-content " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  GridSize ( GridSize : : Type : : MaxContent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is ( Token : : Type : : Ident )  & &  token . ident ( ) . equals_ignoring_ascii_case ( " min-content " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:33:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  GridSize ( GridSize : : Type : : MinContent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  dimension  =  parse_dimension ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! dimension . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( dimension - > is_length ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  GridSize ( dimension - > length ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( dimension - > is_percentage ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  GridSize ( dimension - > percentage ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 15:23:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( dimension - > is_flex ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  GridSize ( dimension - > flex ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2022-10-15 12:58:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < CSS : : GridMinMax >  Parser : : parse_min_max ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://www.w3.org/TR/css-grid-2/#valdef-grid-template-columns-minmax
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 'minmax(min, max)'
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Defines a size range greater than or equal to min and less than or equal to max. If the max is
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // less than the min, then the max will be floored by the min (essentially yielding minmax(min,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // min)). As a maximum, a <flex> value sets the track’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  function_tokens  =  TokenStream ( component_values ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  comma_separated_list  =  parse_a_comma_separated_list_of_component_values ( function_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( comma_separated_list . size ( )  ! =  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  part_one_tokens  {  comma_separated_list [ 0 ]  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    part_one_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! part_one_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  current_token  =  part_one_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  min_grid_size  =  parse_grid_size ( current_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  part_two_tokens  {  comma_separated_list [ 1 ]  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    part_two_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! part_two_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    current_token  =  part_two_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  max_grid_size  =  parse_grid_size ( current_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( min_grid_size . has_value ( )  & &  max_grid_size . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-15 13:04:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // https://www.w3.org/TR/css-grid-2/#valdef-grid-template-columns-minmax
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								        // As a maximum, a <flex> value sets the track’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( min_grid_size . value ( ) . is_flexible_length ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  CSS : : GridMinMax ( min_grid_size . value ( ) ,  max_grid_size . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Optional < CSS : : GridRepeat >  Parser : : parse_repeat ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://www.w3.org/TR/css-grid-2/#repeat-syntax
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 7.2.3.1. Syntax of repeat()
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The generic form of the repeat() syntax is, approximately,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // repeat( [ <integer [1,∞]> | auto-fill | auto-fit ] , <track-list> )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_auto_fill  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_auto_fit  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  function_tokens  =  TokenStream ( component_values ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  comma_separated_list  =  parse_a_comma_separated_list_of_component_values ( function_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( comma_separated_list . size ( )  ! =  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The first argument specifies the number of repetitions.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  part_one_tokens  {  comma_separated_list [ 0 ]  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    part_one_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! part_one_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  current_token  =  part_one_tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  repeat_count  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( current_token . is ( Token : : Type : : Number )  & &  current_token . number ( ) . is_integer ( )  & &  current_token . number_value ( )  >  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        repeat_count  =  current_token . number_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( current_token . is ( Token : : Type : : Ident )  & &  current_token . ident ( ) . equals_ignoring_ascii_case ( " auto-fill " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        is_auto_fill  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( current_token . is ( Token : : Type : : Ident )  & &  current_token . ident ( ) . equals_ignoring_ascii_case ( " auto-fit " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        is_auto_fit  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The second argument is a track list, which is repeated that number of times.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  part_two_tokens  {  comma_separated_list [ 1 ]  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    part_two_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! part_two_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < CSS : : ExplicitGridTrack >  repeat_params ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < Vector < String > >  line_names_list ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  last_object_was_line_names  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( part_two_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  token  =  part_two_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        Vector < String >  line_names ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is_block ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( last_object_was_line_names ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            last_object_was_line_names  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! token . block ( ) . is_square ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  block_tokens  {  token . block ( ) . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            while  ( block_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  current_block_token  =  block_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  maybe_string  =  String : : from_utf8 ( current_block_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( maybe_string . is_error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                line_names . append ( maybe_string . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-21 19:45:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                block_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line_names_list . append ( line_names ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            part_two_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            last_object_was_line_names  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  track_sizing_function  =  parse_track_sizing_function ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! track_sizing_function . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // However, there are some restrictions:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // The repeat() notation can’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( track_sizing_function . value ( ) . is_repeat ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-15 13:04:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // Automatic repetitions (auto-fill or auto-fit) cannot be combined with intrinsic or flexible sizes.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( track_sizing_function . value ( ) . is_default ( )  & &  track_sizing_function . value ( ) . grid_size ( ) . is_flexible_length ( )  & &  ( is_auto_fill  | |  is_auto_fit ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            repeat_params . append ( track_sizing_function . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            part_two_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-15 13:04:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( line_names_list . size ( )  < =  repeat_params . size ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        line_names_list . append ( { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-15 13:04:24 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Thus the precise syntax of the repeat() notation has several forms:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <track-repeat> = repeat( [ <integer [1,∞]> ] , [ <line-names>? <track-size> ]+ <line-names>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <auto-repeat>  = repeat( [ auto-fill | auto-fit ] , [ <line-names>? <fixed-size> ]+ <line-names>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <fixed-repeat> = repeat( [ <integer [1,∞]> ] , [ <line-names>? <fixed-size> ]+ <line-names>? )
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <name-repeat>  = repeat( [ <integer [1,∞]> | auto-fill ], <line-names>+)
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 14:05:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // The <track-repeat> variant can represent the repetition of any <track-size>, but is limited to a
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // fixed number of repetitions.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 14:05:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // The <auto-repeat> variant can repeat automatically to fill a space, but requires definite track
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // sizes so that the number of repetitions can be calculated. It can only appear once in the track
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // list, but the same track list can also contain <fixed-repeat>s.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The <name-repeat> variant is for adding line names to subgrids. It can only be used with the
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // subgrid keyword and cannot specify track sizes, only line names.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // If a repeat() function that is not a <name-repeat> ends up placing two <line-names> adjacent to
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // each other, the name lists are merged. For example, repeat(2, [a] 1fr [b]) is equivalent to [a]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1fr [b a] 1fr [b].
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( is_auto_fill ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  CSS : : GridRepeat ( CSS : : GridTrackSizeList ( repeat_params ,  line_names_list ) ,  CSS : : GridRepeat : : Type : : AutoFill ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else  if  ( is_auto_fit ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  CSS : : GridRepeat ( CSS : : GridTrackSizeList ( repeat_params ,  line_names_list ) ,  CSS : : GridRepeat : : Type : : AutoFit ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  CSS : : GridRepeat ( CSS : : GridTrackSizeList ( repeat_params ,  line_names_list ) ,  repeat_count ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Optional < CSS : : ExplicitGridTrack >  Parser : : parse_track_sizing_function ( ComponentValue  const &  token )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( token . is_function ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  function_token  =  token . function ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( function_token . name ( ) . equals_ignoring_ascii_case ( " repeat " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_repeat  =  parse_repeat ( function_token . values ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( maybe_repeat . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  CSS : : ExplicitGridTrack ( maybe_repeat . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( function_token . name ( ) . equals_ignoring_ascii_case ( " minmax " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_min_max_value  =  parse_min_max ( function_token . values ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( maybe_min_max_value . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  CSS : : ExplicitGridTrack ( maybe_min_max_value . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( auto  maybe_calculated  =  parse_calculated_value ( token ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  CSS : : ExplicitGridTrack ( GridSize ( LengthPercentage ( maybe_calculated . release_nonnull ( ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-14 11:30:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( token . is ( Token : : Type : : Ident )  & &  token . token ( ) . ident ( ) . equals_ignoring_ascii_case ( " auto " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  CSS : : ExplicitGridTrack ( GridSize ( Length : : make_auto ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( token . is_block ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  grid_size  =  parse_grid_size ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! grid_size . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  CSS : : ExplicitGridTrack ( grid_size . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_grid_track_size_list ( Vector < ComponentValue >  const &  component_values ,  bool  allow_separate_line_name_blocks )  
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-06-07 13:04:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1  & &  component_values . first ( ) . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  parse_identifier_value ( component_values . first ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-07 13:04:06 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident  & &  ident - > to_identifier ( )  = =  ValueID : : None )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  GridTrackSizeListStyleValue : : make_none ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < CSS : : ExplicitGridTrack >  track_list ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < Vector < String > >  line_names_list ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  last_object_was_line_names  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  tokens  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is_block ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-29 19:32:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( last_object_was_line_names  & &  ! allow_separate_line_name_blocks ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  GridTrackSizeListStyleValue : : make_auto ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            last_object_was_line_names  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < String >  line_names ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! token . block ( ) . is_square ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  GridTrackSizeListStyleValue : : make_auto ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  block_tokens  {  token . block ( ) . values ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-15 03:13:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            block_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            while  ( block_tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  current_block_token  =  block_tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  maybe_string  =  String : : from_utf8 ( current_block_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( maybe_string . is_error ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                line_names . append ( maybe_string . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-21 19:45:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                block_tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            line_names_list . append ( line_names ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            last_object_was_line_names  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  track_sizing_function  =  parse_track_sizing_function ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! track_sizing_function . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  GridTrackSizeListStyleValue : : make_auto ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Handle multiple repeat values (should combine them here, or remove
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // any other ones if the first one is auto-fill, etc.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            track_list . append ( track_sizing_function . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:45:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( line_names_list . size ( )  < =  track_list . size ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        line_names_list . append ( { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  GridTrackSizeListStyleValue : : create ( CSS : : GridTrackSizeList ( track_list ,  line_names_list ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 20:25:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-grid-1/#grid-auto-flow-property
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < GridAutoFlowStyleValue >  Parser : : parse_grid_auto_flow_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // [ row | column ] || dense
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream < ComponentValue >  tokens  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_axis  =  [ & ] ( )  - >  Optional < GridAutoFlowStyleValue : : Axis >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! token . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  ident  =  token . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " row " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  GridAutoFlowStyleValue : : Axis : : Row ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( ident . equals_ignoring_ascii_case ( " column " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  GridAutoFlowStyleValue : : Axis : : Column ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_dense  =  [ & ] ( )  - >  Optional < GridAutoFlowStyleValue : : Dense >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! token . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  ident  =  token . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . equals_ignoring_ascii_case ( " dense " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  GridAutoFlowStyleValue : : Dense : : Yes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < GridAutoFlowStyleValue : : Axis >  axis ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < GridAutoFlowStyleValue : : Dense >  dense ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( axis  =  parse_axis ( ) ;  axis . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dense  =  parse_dense ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  if  ( dense  =  parse_dense ( ) ;  dense . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        axis  =  parse_axis ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  GridAutoFlowStyleValue : : create ( axis . value_or ( GridAutoFlowStyleValue : : Axis : : Row ) ,  dense . value_or ( GridAutoFlowStyleValue : : Dense : : No ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_grid_auto_track_sizes ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:08:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://www.w3.org/TR/css-grid-2/#auto-tracks
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <track-size>+
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < CSS : : ExplicitGridTrack >  track_list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  tokens  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  track_sizing_function  =  parse_track_sizing_function ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! track_sizing_function . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  GridTrackSizeListStyleValue : : make_auto ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: Handle multiple repeat values (should combine them here, or remove
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // any other ones if the first one is auto-fill, etc.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        track_list . append ( track_sizing_function . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  GridTrackSizeListStyleValue : : create ( CSS : : GridTrackSizeList ( track_list ,  { } ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_grid_track_placement ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // https://www.w3.org/TR/css-grid-2/#line-placement
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Line-based Placement: the grid-row-start, grid-column-start, grid-row-end, and grid-column-end properties
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <grid-line> =
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     auto |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     <custom-ident> |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     [ <integer> && <custom-ident>? ] |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     [ span && [ <integer> || <custom-ident> ] ]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_auto  =  [ ] ( Token  token )  - >  bool  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Ident )  & &  token . ident ( ) . equals_ignoring_ascii_case ( " auto " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_span  =  [ ] ( Token  token )  - >  bool  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Ident )  & &  token . ident ( ) . equals_ignoring_ascii_case ( " span " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_valid_integer  =  [ ] ( Token  token )  - >  bool  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // An <integer> value of zero makes the declaration invalid.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Number )  & &  token . number ( ) . is_integer ( )  & &  token . number_value ( )  ! =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 23:29:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  is_identifier  =  [ ] ( Token  token )  - >  bool  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:46:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // The <custom-ident> additionally excludes the keywords span and auto.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-10 08:48:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Ident )  & &  ! token . ident ( ) . equals_ignoring_ascii_case ( " span " sv )  & &  ! token . ident ( ) . equals_ignoring_ascii_case ( " auto " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:46:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_auto ( current_token ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 23:29:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  GridTrackPlacementStyleValue : : create ( GridTrackPlacement : : make_auto ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_span ( current_token ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 23:29:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  GridTrackPlacementStyleValue : : create ( GridTrackPlacement : : make_span ( 1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_valid_integer ( current_token ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 23:29:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  GridTrackPlacementStyleValue : : create ( GridTrackPlacement : : make_line ( static_cast < int > ( current_token . number_value ( ) ) ,  { } ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_identifier ( current_token ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_string  =  String : : from_utf8 ( current_token . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_string . is_error ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-27 16:27:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  GridTrackPlacementStyleValue : : create ( GridTrackPlacement : : make_line ( { } ,  maybe_string . value ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  span_value  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  span_or_position_value  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 23:29:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    String  identifier_value ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_auto ( current_token ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_span ( current_token ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( span_value  = =  false ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                span_value  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            else 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_valid_integer ( current_token ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( span_or_position_value  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                span_or_position_value  =  static_cast < int > ( current_token . number_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            else 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 23:29:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( is_identifier ( current_token ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( identifier_value . is_empty ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  maybe_string  =  String : : from_utf8 ( current_token . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( maybe_string . is_error ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 23:29:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                identifier_value  =  maybe_string . release_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 17:29:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:46:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 13:06:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Negative integers or zero are invalid.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( span_value  & &  span_or_position_value  <  1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:27:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // If the <integer> is omitted, it defaults to 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( span_or_position_value  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        span_or_position_value  =  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-30 13:46:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-25 23:29:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! identifier_value . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  GridTrackPlacementStyleValue : : create ( GridTrackPlacement : : make_line ( span_or_position_value ,  identifier_value ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  GridTrackPlacementStyleValue : : create ( GridTrackPlacement : : make_span ( span_or_position_value ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:19:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_grid_track_placement_shorthand_value ( PropertyID  property_id ,  Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:19:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  start_property  =  ( property_id  = =  PropertyID : : GridColumn )  ?  PropertyID : : GridColumnStart  :  PropertyID : : GridRowStart ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  end_property  =  ( property_id  = =  PropertyID : : GridColumn )  ?  PropertyID : : GridColumnEnd  :  PropertyID : : GridRowEnd ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 13:50:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  track_start_placement_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( current_token . is ( Token : : Type : : Delim )  & &  current_token . delim ( )  = =  " / " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        track_start_placement_tokens . append ( current_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 13:50:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  track_end_placement_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            track_end_placement_tokens . append ( current_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 13:50:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parsed_start_value  =  parse_grid_track_placement ( track_start_placement_tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:19:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( parsed_start_value  & &  track_end_placement_tokens . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( property_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  start_property ,  end_property  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  parsed_start_value . release_nonnull ( ) ,  GridTrackPlacementStyleValue : : create ( GridTrackPlacement : : make_auto ( ) )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parsed_end_value  =  parse_grid_track_placement ( track_end_placement_tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:19:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( parsed_start_value  & &  parsed_end_value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ShorthandStyleValue : : create ( property_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  start_property ,  end_property  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            {  parsed_start_value . release_nonnull ( ) ,  parsed_end_value . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-29 19:32:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-grid-2/#explicit-grid-shorthand
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								// 7.4. Explicit Grid Shorthand: the grid-template property
  
						 
					
						
							
								
									
										
										
										
											2023-09-20 14:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_grid_track_size_list_shorthand_value ( PropertyID  property_id ,  Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-04-29 19:32:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The grid-template property is a shorthand for setting grid-template-columns, grid-template-rows,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // and grid-template-areas in a single declaration. It has several distinct syntax forms:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // none
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - Sets all three properties to their initial values (none).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <'grid-template-rows'> / <'grid-template-columns'>
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - Sets grid-template-rows and grid-template-columns to the specified values, respectively, and sets grid-template-areas to none.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // [ <line-names>? <string> <track-size>? <line-names>? ]+ [ / <explicit-track-list> ]?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - Sets grid-template-areas to the strings listed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - Sets grid-template-rows to the <track-size>s following each string (filling in auto for any missing sizes),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //      and splicing in the named lines defined before/after each size.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    - Sets grid-template-columns to the track listing specified after the slash (or none, if not specified).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  template_rows_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  template_columns_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  template_area_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    int  forward_slash_index  =  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( size_t  x  =  0 ;  x  <  component_values . size ( ) ;  x + + )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 14:28:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( component_values [ x ] . is_delim ( ' / ' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-29 19:32:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            forward_slash_index  =  x ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( size_t  x  =  0 ;  x  <  ( forward_slash_index  >  - 1  ?  forward_slash_index  :  component_values . size ( ) ) ;  x + + )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( component_values [ x ] . is_token ( )  & &  component_values [ x ] . token ( ) . is ( Token : : Type : : String ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            template_area_tokens . append ( component_values [ x ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            template_rows_tokens . append ( component_values [ x ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( forward_slash_index  >  - 1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( size_t  x  =  forward_slash_index  +  1 ;  x  <  component_values . size ( ) ;  x + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            template_columns_tokens . append ( component_values [ x ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parsed_template_areas_values  =  parse_grid_template_areas_value ( template_area_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parsed_template_rows_values  =  parse_grid_track_size_list ( template_rows_tokens ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parsed_template_columns_values  =  parse_grid_track_size_list ( template_columns_tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 14:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( property_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : GridTemplateAreas ,  PropertyID : : GridTemplateRows ,  PropertyID : : GridTemplateColumns  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  parsed_template_areas_values . release_nonnull ( ) ,  parsed_template_rows_values . release_nonnull ( ) ,  parsed_template_columns_values . release_nonnull ( )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-29 19:32:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_grid_area_shorthand_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-01-16 19:02:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  tokens  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Token  current_token ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parse_placement_tokens  =  [ & ] ( Vector < ComponentValue > &  placement_tokens ,  bool  check_for_delimiter  =  true )  - >  void  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( check_for_delimiter  & &  current_token . is ( Token : : Type : : Delim )  & &  current_token . delim ( )  = =  " / " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            placement_tokens . append ( current_token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            current_token  =  tokens . next_token ( ) . token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  row_start_placement_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    parse_placement_tokens ( row_start_placement_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  column_start_placement_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        parse_placement_tokens ( column_start_placement_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  row_end_placement_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        parse_placement_tokens ( row_end_placement_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  column_end_placement_tokens ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        parse_placement_tokens ( column_end_placement_tokens ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://www.w3.org/TR/css-grid-2/#placement-shorthands
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // The grid-area property is a shorthand for grid-row-start, grid-column-start, grid-row-end and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // grid-column-end.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  row_start_style_value  =  parse_grid_track_placement ( row_start_placement_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  column_start_style_value  =  parse_grid_track_placement ( column_start_placement_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  row_end_style_value  =  parse_grid_track_placement ( row_end_placement_tokens ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  column_end_style_value  =  parse_grid_track_placement ( column_end_placement_tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 19:02:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // If four <grid-line> values are specified, grid-row-start is set to the first value, grid-column-start
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // is set to the second value, grid-row-end is set to the third value, and grid-column-end is set to the
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // fourth value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  row_start  =  GridTrackPlacement : : make_auto ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  column_start  =  GridTrackPlacement : : make_auto ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  row_end  =  GridTrackPlacement : : make_auto ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  column_end  =  GridTrackPlacement : : make_auto ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( row_start_style_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        row_start  =  row_start_style_value . release_nonnull ( ) - > as_grid_track_placement ( ) . grid_track_placement ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // When grid-column-start is omitted, if grid-row-start is a <custom-ident>, all four longhands are set to
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // that value. Otherwise, it is set to auto.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( column_start_style_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        column_start  =  column_start_style_value . release_nonnull ( ) - > as_grid_track_placement ( ) . grid_track_placement ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        column_start  =  row_start ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // When grid-row-end is omitted, if grid-row-start is a <custom-ident>, grid-row-end is set to that
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <custom-ident>; otherwise, it is set to auto.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( row_end_style_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        row_end  =  row_end_style_value . release_nonnull ( ) - > as_grid_track_placement ( ) . grid_track_placement ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        row_end  =  column_start ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // When grid-column-end is omitted, if grid-column-start is a <custom-ident>, grid-column-end is set to
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // that <custom-ident>; otherwise, it is set to auto.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( column_end_style_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        column_end  =  column_end_style_value . release_nonnull ( ) - > as_grid_track_placement ( ) . grid_track_placement ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        column_end  =  row_end ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 14:47:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  ShorthandStyleValue : : create ( PropertyID : : GridArea , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  PropertyID : : GridRowStart ,  PropertyID : : GridColumnStart ,  PropertyID : : GridRowEnd ,  PropertyID : : GridColumnEnd  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        {  GridTrackPlacementStyleValue : : create ( row_start ) ,  GridTrackPlacementStyleValue : : create ( column_start ) ,  GridTrackPlacementStyleValue : : create ( row_end ) ,  GridTrackPlacementStyleValue : : create ( column_end )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 19:02:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_grid_shorthand_value ( Vector < ComponentValue >  const &  component_value )  
						 
					
						
							
								
									
										
										
										
											2023-05-27 02:58:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <'grid-template'> |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: <'grid-template-rows'> / [ auto-flow && dense? ] <'grid-auto-columns'>? |
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: [ auto-flow && dense? ] <'grid-auto-rows'>? / <'grid-template-columns'>
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 14:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  parse_grid_track_size_list_shorthand_value ( PropertyID : : Grid ,  component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-27 02:58:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_grid_template_areas_value ( Vector < ComponentValue >  const &  component_values )  
						 
					
						
							
								
									
										
										
										
											2023-01-16 18:17:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < Vector < String > >  grid_area_rows ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  component_value  :  component_values )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Vector < String >  grid_area_columns ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( component_value . is ( Token : : Type : : String ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const  parts  =  MUST ( MUST ( String : : from_utf8 ( component_value . token ( ) . string ( ) ) ) . split ( '   ' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 18:17:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( auto &  part  :  parts )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                grid_area_columns . append ( part ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        grid_area_rows . append ( move ( grid_area_columns ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  GridTemplateAreaStyleValue : : create ( grid_area_rows ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 18:17:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 03:56:02 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								static  bool  block_contains_var_or_attr ( Block  const &  block ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								static  bool  function_contains_var_or_attr ( Function  const &  function )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( function . name ( ) . equals_ignoring_ascii_case ( " var " sv )  | |  function . name ( ) . equals_ignoring_ascii_case ( " attr " sv ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  token  :  function . values ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is_function ( )  & &  function_contains_var_or_attr ( token . function ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is_block ( )  & &  block_contains_var_or_attr ( token . block ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  block_contains_var_or_attr ( Block  const &  block )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const &  token  :  block . values ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is_function ( )  & &  function_contains_var_or_attr ( token . function ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is_block ( )  & &  block_contains_var_or_attr ( token . block ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-07 22:48:11 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2023-05-26 03:56:02 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Parser : : ParseErrorOr < NonnullRefPtr < StyleValue > >  Parser : : parse_css_value ( PropertyID  property_id ,  TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-09-11 20:39:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    m_context . set_current_property_id ( property_id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-31 11:43:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  component_values ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 23:33:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  contains_var_or_attr  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 13:05:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    bool  const  property_accepts_custom_ident  =  property_accepts_type ( property_id ,  ValueType : : CustomIdent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( tokens . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-10 12:50:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( token . is ( Token : : Type : : Semicolon ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            tokens . reconsume_current_input_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-03 12:32:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( property_id  ! =  PropertyID : : Custom )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( token . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 13:05:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! property_accepts_custom_ident  & &  token . is ( Token : : Type : : Ident )  & &  has_ignored_vendor_prefix ( token . token ( ) . ident ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  ParseError : : IncludesIgnoredVendorPrefix ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-03 12:32:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 23:33:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! contains_var_or_attr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 03:56:02 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( token . is_function ( )  & &  function_contains_var_or_attr ( token . function ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 23:33:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                contains_var_or_attr  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 03:56:02 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            else  if  ( token . is_block ( )  & &  block_contains_var_or_attr ( token . block ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 23:33:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                contains_var_or_attr  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-03 12:32:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        component_values . append ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-29 23:33:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( property_id  = =  PropertyID : : Custom  | |  contains_var_or_attr ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  UnresolvedStyleValue : : create ( move ( component_values ) ,  contains_var_or_attr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-03 12:32:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-08-19 15:45:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_builtin_value ( component_values . first ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-19 15:45:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Special-case property handling
 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    switch  ( property_id )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 15:25:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : AspectRatio : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_aspect_ratio_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-08 15:25:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackdropFilter : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_filter_value_list_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-15 08:31:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 14:56:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Background : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_background_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundAttachment : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundClip : 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 16:20:30 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundImage : 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-08 17:19:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundOrigin : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_simple_comma_separated_value_list ( property_id ,  component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundPosition : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_comma_separated_value_list ( component_values ,  [ this ] ( auto &  tokens )  {  return  parse_single_background_position_value ( tokens ) ;  } ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-31 16:02:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundPositionX : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundPositionY : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_comma_separated_value_list ( component_values ,  [ this ,  property_id ] ( auto &  tokens )  {  return  parse_single_background_position_x_or_y_value ( tokens ,  property_id ) ;  } ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-03 00:04:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-10 10:21:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundRepeat : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_comma_separated_value_list ( component_values ,  [ this ] ( auto &  tokens )  {  return  parse_single_background_repeat_value ( tokens ) ;  } ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BackgroundSize : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_comma_separated_value_list ( component_values ,  [ this ] ( auto &  tokens )  {  return  parse_single_background_size_value ( tokens ) ;  } ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-11-05 13:44:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 21:11:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Border : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderBottom : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderLeft : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderRight : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderTop : 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 12:50:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_border_value ( property_id ,  component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderTopLeftRadius : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderTopRightRadius : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderBottomRightRadius : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderBottomLeftRadius : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_border_radius_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-06 16:55:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BorderRadius : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_border_radius_shorthand_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : BoxShadow : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_shadow_value ( component_values ,  AllowInsetKeyword : : Yes ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Content : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_content_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-23 19:56:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Display : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_display_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-26 21:05:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 17:48:08 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Flex : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_flex_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-05 17:19:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : FlexFlow : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_flex_flow_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Font : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_font_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : FontFamily :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  tokens_without_whitespace  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_font_family_value ( tokens_without_whitespace ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-24 16:09:38 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridColumn : 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:19:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_placement_shorthand_value ( property_id ,  component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 19:02:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridArea : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_area_shorthand_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 19:02:39 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 20:25:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridAutoFlow : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_auto_flow_value ( component_values ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 18:17:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridTemplateAreas : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_template_areas_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-16 18:17:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridColumnEnd : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_placement ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridColumnStart : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_placement ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridRow : 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 16:19:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_placement_shorthand_value ( property_id ,  component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 20:00:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridRowEnd : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_placement ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridRowStart : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_placement ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:58:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-27 02:58:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Grid : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_shorthand_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-27 02:58:19 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-29 19:32:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridTemplate : 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 14:50:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_size_list_shorthand_value ( property_id ,  component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-29 19:32:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridTemplateColumns : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_size_list ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridTemplateRows : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_track_size_list ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:08:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridAutoColumns : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_auto_track_sizes ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:08:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : GridAutoRows : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_grid_auto_track_sizes ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-21 18:08:41 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-23 19:49:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 15:56:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : ListStyle : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_list_style_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-07 15:29:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : MathDepth : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_math_depth_value ( component_values ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-16 13:52:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : ObjectPosition : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: This should use a parse_position compatible to VALUES-4
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //        and not the background position, which is almost the same.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_comma_separated_value_list ( component_values ,  [ this ] ( auto &  tokens )  {  return  parse_single_background_position_value ( tokens ) ;  } ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-09 14:54:40 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Overflow : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_overflow_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-29 16:34:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : PlaceContent : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_place_content_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-29 16:34:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-17 16:34:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : PlaceItems : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_place_items_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-17 16:34:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : PlaceSelf : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_place_self_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-12 11:34:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Quotes : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_quotes_value ( component_values ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-04 14:04:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-04 12:34:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : TextDecoration : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_text_decoration_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : TextDecorationLine :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:35:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        TokenStream  value_tokens  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  parsed_value  =  parse_text_decoration_line_value ( value_tokens ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:35:25 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( parsed_value  & &  ! value_tokens . has_next_token ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-14 16:22:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 21:16:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : TextShadow : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_shadow_value ( component_values ,  AllowInsetKeyword : : No ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 21:16:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : Transform : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_transform_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-18 17:20:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-21 19:11:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    case  PropertyID : : TransformOrigin : 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_transform_origin_value ( component_values ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-02 13:03:51 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-04-27 11:04:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError  : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-03 11:37:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 14:12:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:31:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // If there's only 1 ComponentValue, we can only produce a single StyleValue.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 19:44:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( component_values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:31:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  stream  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  parsed_value  =  parse_css_value_for_property ( property_id ,  stream ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:31:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  parsed_value . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-02 17:03:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        StyleValueVector  parsed_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  stream  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        while  ( auto  parsed_value  =  parse_css_value_for_property ( property_id ,  stream ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            parsed_values . append ( parsed_value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! stream . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Some types (such as <ratio>) can be made from multiple ComponentValues, so if we only made 1 StyleValue, return it directly.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( parsed_values . size ( )  = =  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  * parsed_values . take_first ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! parsed_values . is_empty ( )  & &  parsed_values . size ( )  < =  property_maximum_value_count ( property_id ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  StyleValueList : : create ( move ( parsed_values ) ,  StyleValueList : : Separator : : Space ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // We have multiple values, but the property claims to accept only a single one, check if it's a shorthand property.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  unassigned_properties  =  longhands_for_shorthand ( property_id ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( unassigned_properties . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:31:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  stream  =  TokenStream  {  component_values  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    HashMap < UnderlyingType < PropertyID > ,  Vector < ValueComparingNonnullRefPtr < StyleValue  const > > >  assigned_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( stream . has_next_token ( )  & &  ! unassigned_properties . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  property_and_value  =  parse_css_value_for_properties ( unassigned_properties ,  stream ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( property_and_value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  property  =  property_and_value - > property ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  value  =  property_and_value - > style_value ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  values  =  assigned_values . ensure ( to_underlying ( property ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( values . size ( )  +  1  = =  property_maximum_value_count ( property ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // We're done with this property, move on to the next one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                unassigned_properties . remove_first_matching ( [ & ] ( auto &  unassigned_property )  {  return  unassigned_property  = =  property ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            values . append ( value . release_nonnull ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // No property matched, so we're done.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln ( " No property (from {} properties) matched {} " ,  unassigned_properties . size ( ) ,  stream . peek_token ( ) . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  id  :  unassigned_properties ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dbgln ( "     {} " ,  string_from_property_id ( id ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-08-14 14:01:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  property  :  unassigned_properties ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        assigned_values . ensure ( to_underlying ( property ) ) . append ( property_initial_value ( m_context . realm ( ) ,  property ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:31:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    stream . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( stream . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  ParseError : : SyntaxError ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:31:07 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < PropertyID >  longhand_properties ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    longhand_properties . ensure_capacity ( assigned_values . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  it  :  assigned_values ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        longhand_properties . unchecked_append ( static_cast < PropertyID > ( it . key ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    StyleValueVector  longhand_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    longhand_values . ensure_capacity ( assigned_values . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  it  :  assigned_values )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( it . value . size ( )  = =  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            longhand_values . unchecked_append ( it . value . take_first ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            longhand_values . unchecked_append ( StyleValueList : : create ( move ( it . value ) ,  StyleValueList : : Separator : : Space ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 23:16:43 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-19 16:26:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  {  ShorthandStyleValue : : create ( property_id ,  move ( longhand_properties ) ,  move ( longhand_values ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 16:20:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								RefPtr < StyleValue >  Parser : : parse_css_value_for_property ( PropertyID  property_id ,  TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  parse_css_value_for_properties ( {  & property_id ,  1  } ,  tokens ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . map ( [ ] ( auto &  it )  {  return  it . style_value ;  } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        . value_or ( nullptr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								Optional < Parser : : PropertyAndValue >  Parser : : parse_css_value_for_properties ( ReadonlySpan < PropertyID >  property_ids ,  TokenStream < ComponentValue > &  tokens )  
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  any_property_accepts_type  =  [ ] ( ReadonlySpan < PropertyID >  property_ids ,  ValueType  value_type )  - >  Optional < PropertyID >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  const &  property  :  property_ids )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( property_accepts_type ( property ,  value_type ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  property ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  any_property_accepts_type_percentage  =  [ ] ( ReadonlySpan < PropertyID >  property_ids ,  ValueType  value_type )  - >  Optional < PropertyID >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  const &  property  :  property_ids )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( property_accepts_type ( property ,  value_type )  & &  property_accepts_type ( property ,  ValueType : : Percentage ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  property ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  any_property_accepts_identifier  =  [ ] ( ReadonlySpan < PropertyID >  property_ids ,  ValueID  identifier )  - >  Optional < PropertyID >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  const &  property  :  property_ids )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( property_accepts_identifier ( property ,  identifier ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  property ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto &  peek_token  =  tokens . peek_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 16:54:15 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : EasingFunction ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_easing_function  =  parse_easing_value ( tokens ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-06 16:54:15 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  maybe_easing_function  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( peek_token . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: We do not try to parse "CSS-wide keywords" here. https://www.w3.org/TR/css-values-4/#common-keywords
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //       These are only valid on their own, and so should be parsed directly in `parse_css_value()`.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  ident  =  value_id_from_string ( peek_token . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ident . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  property  =  any_property_accepts_identifier ( property_ids ,  ident . value ( ) ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  PropertyAndValue  {  * property ,  IdentifierStyleValue : : create ( ident . value ( ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-25 12:43:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // Custom idents
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : CustomIdent ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  CustomIdentStyleValue : : create ( MUST ( FlyString : : from_utf8 ( peek_token . token ( ) . ident ( ) ) ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-25 12:43:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Color ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_color  =  parse_color_value ( peek_token ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  maybe_color  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Image ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_image  =  parse_image_value ( peek_token ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  maybe_image  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 15:42:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Ratio ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_ratio  =  parse_ratio_value ( tokens ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-06 15:42:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  maybe_ratio  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  property_accepting_integer  =  any_property_accepts_type ( property_ids ,  ValueType : : Integer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  property_accepting_number  =  any_property_accepts_type ( property_ids ,  ValueType : : Number ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  property_accepts_numeric  =  property_accepting_integer . has_value ( )  | |  property_accepting_number . has_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( peek_token . is ( Token : : Type : : Number )  & &  property_accepts_numeric )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( property_accepting_integer . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  integer  =  parse_integer_value ( tokens ) ;  integer  & &  property_accepts_integer ( * property_accepting_integer ,  integer - > as_integer ( ) . integer ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  PropertyAndValue  {  * property_accepting_integer ,  integer  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( property_accepting_number . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  number  =  parse_number_value ( tokens ) ;  number  & &  property_accepts_number ( * property_accepting_number ,  number - > as_number ( ) . number ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return  PropertyAndValue  {  * property_accepting_number ,  number  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-01 17:01:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( peek_token . is ( Token : : Type : : Percentage ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 15:15:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  percentage  =  Percentage ( peek_token . token ( ) . percentage ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Percentage ) ;  property . has_value ( )  & &  property_accepts_percentage ( * property ,  percentage ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  PercentageStyleValue : : create ( percentage )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Rect ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_rect  =  parse_rect_value ( peek_token ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  maybe_rect  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( peek_token . is ( Token : : Type : : String ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : String ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  StringStyleValue : : create ( MUST ( String : : from_utf8 ( tokens . next_token ( ) . token ( ) . string ( ) ) ) )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Url ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  url  =  parse_url_value ( peek_token ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  url  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  property_accepts_dimension  =  any_property_accepts_type ( property_ids ,  ValueType : : Angle ) . has_value ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 15:18:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        | |  any_property_accepts_type ( property_ids ,  ValueType : : Flex ) . has_value ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 14:18:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        | |  any_property_accepts_type ( property_ids ,  ValueType : : Frequency ) . has_value ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        | |  any_property_accepts_type ( property_ids ,  ValueType : : Length ) . has_value ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        | |  any_property_accepts_type ( property_ids ,  ValueType : : Percentage ) . has_value ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        | |  any_property_accepts_type ( property_ids ,  ValueType : : Resolution ) . has_value ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        | |  any_property_accepts_type ( property_ids ,  ValueType : : Time ) . has_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( property_accepts_dimension )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 15:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( peek_token . is ( Token : : Type : : Number )  & &  m_context . is_parsing_svg_presentation_attribute ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  token  =  tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // https://svgwg.org/svg2-draft/types.html#presentation-attribute-css-value
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // We need to allow <number> in any place that expects a <length> or <angle>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: How should these numbers be interpreted? https://github.com/w3c/svgwg/issues/792
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //        For now: Convert them to px lengths, or deg angles.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  angle  =  Angle : : make_degrees ( token . token ( ) . number_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Angle ) ;  property . has_value ( )  & &  property_accepts_angle ( * property ,  angle ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  PropertyAndValue  {  * property ,  AngleStyleValue : : create ( angle )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  length  =  Length : : make_px ( CSSPixels : : nearest_value_for ( token . token ( ) . number_value ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Length ) ;  property . has_value ( )  & &  property_accepts_length ( * property ,  length ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  PropertyAndValue  {  * property ,  LengthStyleValue : : create ( length )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  transaction  =  tokens . begin_transaction ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_dimension  =  parse_dimension ( peek_token ) ;  maybe_dimension . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  dimension  =  maybe_dimension . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( dimension . is_angle ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 15:15:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  angle  =  dimension . angle ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Angle ) ;  property . has_value ( )  & &  property_accepts_angle ( * property ,  angle ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  AngleStyleValue : : create ( angle )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 15:18:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( dimension . is_flex ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto  flex  =  dimension . flex ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Flex ) ;  property . has_value ( )  & &  property_accepts_flex ( * property ,  flex ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction . commit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  FlexStyleValue : : create ( flex )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( dimension . is_frequency ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 15:15:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  frequency  =  dimension . frequency ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Frequency ) ;  property . has_value ( )  & &  property_accepts_frequency ( * property ,  frequency ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  FrequencyStyleValue : : create ( frequency )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( dimension . is_length ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 15:15:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  length  =  dimension . length ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Length ) ;  property . has_value ( )  & &  property_accepts_length ( * property ,  length ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  LengthStyleValue : : create ( length )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( dimension . is_resolution ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 15:15:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  resolution  =  dimension . resolution ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Resolution ) ;  property . has_value ( )  & &  property_accepts_resolution ( * property ,  resolution ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  ResolutionStyleValue : : create ( resolution )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( dimension . is_time ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 15:15:45 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                auto  time  =  dimension . time ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Time ) ;  property . has_value ( )  & &  property_accepts_time ( * property ,  time ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    transaction . commit ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:00:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  TimeStyleValue : : create ( time )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 20:28:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // In order to not end up parsing `calc()` and other math expressions multiple times,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // we parse it once, and then see if its resolved type matches what the property accepts.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( peek_token . is_function ( )  & &  ( property_accepts_dimension  | |  property_accepts_numeric ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  maybe_calculated  =  parse_calculated_value ( peek_token ) ;  maybe_calculated )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            ( void ) tokens . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-17 14:43:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  calculated  =  * maybe_calculated ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 12:33:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // This is a bit sensitive to ordering: `<foo>` and `<percentage>` have to be checked before `<foo-percentage>`.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-25 15:26:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: When parsing SVG presentation attributes, <number> is permitted wherever <length>, <length-percentage>, or <angle> are.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //        The specifics are unclear, so I'm ignoring this for calculated values for now.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            //        See https://github.com/w3c/svgwg/issues/792
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 12:33:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( calculated . resolves_to_percentage ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Percentage ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_angle ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Angle ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 12:33:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_angle_percentage ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type_percentage ( property_ids ,  ValueType : : Angle ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 15:18:14 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_flex ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Flex ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_frequency ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Frequency ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 12:33:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_frequency_percentage ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type_percentage ( property_ids ,  ValueType : : Frequency ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_number ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-27 22:56:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( property_accepts_numeric )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  property_or_resolved  =  property_accepting_integer . value_or_lazy_evaluated ( [ property_accepting_number ] ( )  {  return  property_accepting_number . value ( ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  property_or_resolved ,  calculated  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 12:33:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_number_percentage ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type_percentage ( property_ids ,  ValueType : : Number ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_length ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Length ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 12:33:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_length_percentage ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type_percentage ( property_ids ,  ValueType : : Length ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_time ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Time ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-30 12:33:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  if  ( calculated . resolves_to_time_percentage ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( auto  property  =  any_property_accepts_type_percentage ( property_ids ,  ValueType : : Time ) ;  property . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-30 16:29:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  PropertyAndValue  {  * property ,  calculated  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-15 16:37:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  property  =  any_property_accepts_type ( property_ids ,  ValueType : : Paint ) ;  property . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  value  =  parse_paint_value ( tokens ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-15 16:37:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  PropertyAndValue  {  * property ,  value . release_nonnull ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:26:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  OptionalNone  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-17 17:23:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								class  UnparsedCalculationNode  final  :  public  CalculationNode  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								public :  
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    static  NonnullOwnPtr < UnparsedCalculationNode >  create ( ComponentValue  component_value ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  adopt_own ( * new  ( nothrow )  UnparsedCalculationNode ( move ( component_value ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  ~ UnparsedCalculationNode ( )  =  default ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ComponentValue &  component_value ( )  {  return  m_component_value ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 14:08:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  String  to_string ( )  const  override  {  VERIFY_NOT_REACHED ( ) ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  Optional < CalculatedStyleValue : : ResolvedType >  resolved_type ( )  const  override  {  VERIFY_NOT_REACHED ( ) ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-05 19:58:13 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  Optional < CSSNumericType >  determine_type ( Web : : CSS : : PropertyID )  const  override  {  VERIFY_NOT_REACHED ( ) ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  bool  contains_percentage ( )  const  override  {  VERIFY_NOT_REACHED ( ) ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-02 12:39:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  CalculatedStyleValue : : CalculationResult  resolve ( Optional < Length : : ResolutionContext  const & > ,  CalculatedStyleValue : : PercentageBasis  const & )  const  override  {  VERIFY_NOT_REACHED ( ) ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  void  for_each_child_node ( AK : : Function < void ( NonnullOwnPtr < CalculationNode > & ) >  const & )  override  {  } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 14:13:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    virtual  void  dump ( StringBuilder &  builder ,  int  indent )  const  override 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-22 14:13:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        builder . appendff ( " {: >{}}UNPARSED({}) \n " ,  " " ,  indent ,  m_component_value . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								private :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    UnparsedCalculationNode ( ComponentValue  component_value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        :  CalculationNode ( Type : : Unparsed ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        ,  m_component_value ( move ( component_value ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    ComponentValue  m_component_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ;  
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 21:04:16 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://html.spec.whatwg.org/multipage/images.html#parsing-a-sizes-attribute
  
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								LengthOrCalculated  Parser : : Parser : : parse_as_sizes_attribute ( )  
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Let unparsed sizes list be the result of parsing a comma-separated list of component values
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    from the value of element's sizes attribute (or the empty string, if the attribute is absent).
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  unparsed_sizes_list  =  parse_a_comma_separated_list_of_component_values ( m_token_stream ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Let size be null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < LengthOrCalculated >  size ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. For each unparsed size in unparsed sizes list:
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  unparsed_size  :  unparsed_sizes_list )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. Remove all consecutive <whitespace-token>s from the end of unparsed size.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    If unparsed size is now empty, that is a parse error; continue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        while  ( ! unparsed_size . is_empty ( )  & &  unparsed_size . last ( ) . is_token ( )  & &  unparsed_size . last ( ) . token ( ) . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            unparsed_size . take_last ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( unparsed_size . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If the last component value in unparsed size is a valid non-negative <source-size-value>,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    let size be its value and remove the component value from unparsed size.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    FIXME: Any CSS function other than the math functions is invalid.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    Otherwise, there is a parse error; continue.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  source_size_value  =  parse_source_size_value ( unparsed_size . last ( ) ) ;  source_size_value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            size  =  source_size_value . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            unparsed_size . take_last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 3. Remove all consecutive <whitespace-token>s from the end of unparsed size.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        while  ( ! unparsed_size . is_empty ( )  & &  unparsed_size . last ( ) . is_token ( )  & &  unparsed_size . last ( ) . token ( ) . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            unparsed_size . take_last ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // If unparsed size is now empty, then return size.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( unparsed_size . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  size . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // FIXME: If this was not the keyword auto and it was not the last item in unparsed sizes list, that is a parse error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 4. Parse the remaining component values in unparsed size as a <media-condition>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    If it does not parse correctly, or it does parse correctly but the <media-condition> evaluates to false, continue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        TokenStream < ComponentValue >  token_stream  {  unparsed_size  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  media_condition  =  parse_media_condition ( token_stream ,  MediaCondition : : AllowOr : : Yes ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( media_condition  & &  media_condition - > evaluate ( * m_context . window ( ) )  = =  MatchResult : : True )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  size . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-28 15:52:06 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 5. If size is not auto, then return size.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( size . value ( ) . is_calculated ( )  | |  ! size . value ( ) . value ( ) . is_auto ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  size . value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-09 11:48:45 +03:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  Length ( 100 ,  Length : : Type : : Vw ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://www.w3.org/TR/css-values-4/#parse-a-calculation
  
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								OwnPtr < CalculationNode >  Parser : : parse_a_calculation ( Vector < ComponentValue >  const &  original_values )  
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. Discard any <whitespace-token>s from values.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								    // 2. An item in values is an “operator” if it’ ’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    struct  Operator  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        char  delim ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    using  Value  =  Variant < NonnullOwnPtr < CalculationNode > ,  Operator > ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < Value >  values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto &  value  :  original_values )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . is ( Token : : Type : : Whitespace ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . is ( Token : : Type : : Delim ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( first_is_one_of ( value . token ( ) . delim ( ) ,  static_cast < u32 > ( ' + ' ) ,  static_cast < u32 > ( ' - ' ) ,  static_cast < u32 > ( ' * ' ) ,  static_cast < u32 > ( ' / ' ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // NOTE: Sequential operators are invalid syntax.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! values . is_empty ( )  & &  values . last ( ) . has < Operator > ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                values . append ( Operator  {  static_cast < char > ( value . token ( ) . delim ( ) )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 21:24:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-07-08 16:55:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  maybe_constant  =  CalculationNode : : constant_type_from_string ( value . token ( ) . ident ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( maybe_constant . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                values . append ( {  ConstantCalculationNode : : create ( maybe_constant . value ( ) )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-26 21:24:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            values . append ( {  NumericCalculationNode : : create ( value . token ( ) . number ( ) )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  dimension  =  parse_dimension ( value ) ;  dimension . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( dimension - > is_angle ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                values . append ( {  NumericCalculationNode : : create ( dimension - > angle ( ) )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            else  if  ( dimension - > is_frequency ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                values . append ( {  NumericCalculationNode : : create ( dimension - > frequency ( ) )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            else  if  ( dimension - > is_length ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                values . append ( {  NumericCalculationNode : : create ( dimension - > length ( ) )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            else  if  ( dimension - > is_percentage ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                values . append ( {  NumericCalculationNode : : create ( dimension - > percentage ( ) )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            // FIXME: Resolutions, once calc() supports them.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            else  if  ( dimension - > is_time ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                values . append ( {  NumericCalculationNode : : create ( dimension - > time ( ) )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-10 22:54:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            else  if  ( dimension - > is_flex ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // https://www.w3.org/TR/css3-grid-layout/#fr-unit
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                // NOTE: <flex> values are not <length>s (nor are they compatible with <length>s, like some <percentage> values),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                //       so they cannot be represented in or combined with other unit types in calc() expressions.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-10-10 22:54:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        values . append ( {  UnparsedCalculationNode : : create ( value )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // If we have no values, the syntax is invalid.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( values . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // NOTE: If the first or last value is an operator, the syntax is invalid.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( values . first ( ) . has < Operator > ( )  | |  values . last ( ) . has < Operator > ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-31 15:10:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Collect children into Product and Invert nodes.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    For every consecutive run of value items in values separated by "*" or "/" operators:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Optional < size_t >  first_product_operator  =  values . find_first_index_if ( [ ] ( auto  const &  item )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  item . template  has < Operator > ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                & &  first_is_one_of ( item . template  get < Operator > ( ) . delim ,  ' * ' ,  ' / ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! first_product_operator . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  start_of_run  =  first_product_operator . value ( )  -  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  end_of_run  =  first_product_operator . value ( )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  i  =  start_of_run  +  1 ;  i  <  values . size ( ) ;  i  + =  2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  item  =  values [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! item . has < Operator > ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                end_of_run  =  i  -  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  delim  =  item . get < Operator > ( ) . delim ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! first_is_one_of ( delim ,  ' * ' ,  ' / ' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                end_of_run  =  i  -  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. For each "/" operator in the run, replace its right-hand value item rhs with an Invert node containing rhs as its child.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        Vector < NonnullOwnPtr < CalculationNode > >  run_values ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        run_values . append ( move ( values [ start_of_run ] . get < NonnullOwnPtr < CalculationNode > > ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  i  =  start_of_run  +  1 ;  i  < =  end_of_run ;  i  + =  2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  operator_  =  values [ i ] . get < Operator > ( ) . delim ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  rhs  =  values [ i  +  1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( operator_  = =  ' / ' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                run_values . append ( InvertCalculationNode : : create ( move ( rhs . get < NonnullOwnPtr < CalculationNode > > ( ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( operator_  = =  ' * ' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            run_values . append ( move ( rhs . get < NonnullOwnPtr < CalculationNode > > ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. Replace the entire run with a Product node containing the value items of the run as its children.
 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto  product_node  =  ProductCalculationNode : : create ( move ( run_values ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        values . remove ( start_of_run ,  end_of_run  -  start_of_run  +  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        values . insert ( start_of_run ,  {  move ( product_node )  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 4. Collect children into Sum and Negate nodes.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Optional < NonnullOwnPtr < CalculationNode > >  single_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // 1. For each "-" operator item in values, replace its right-hand value item rhs with a Negate node containing rhs as its child.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  i  =  0u ;  i  <  values . size ( ) ;  + + i )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  maybe_minus_operator  =  values [ i ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! maybe_minus_operator . has < Operator > ( )  | |  maybe_minus_operator . get < Operator > ( ) . delim  ! =  ' - ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  rhs_index  =  + + i ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  rhs  =  values [ rhs_index ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            NonnullOwnPtr < CalculationNode >  negate_node  =  NegateCalculationNode : : create ( move ( rhs . get < NonnullOwnPtr < CalculationNode > > ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            values . remove ( rhs_index ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            values . insert ( rhs_index ,  move ( negate_node ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If values has only one item, and it is a Product node or a parenthesized simple block, replace values with that item.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( values . size ( )  = =  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            values . first ( ) . visit ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                [ & ] ( ComponentValue &  component_value )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( component_value . is_block ( )  & &  component_value . block ( ) . is_paren ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                        single_value  =  UnparsedCalculationNode : : create ( component_value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                [ & ] ( NonnullOwnPtr < CalculationNode > &  node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    if  ( node - > type ( )  = =  CalculationNode : : Type : : Product ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        single_value  =  move ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } , 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                [ ] ( auto & )  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //    Otherwise, replace values with a Sum node containing the value items of values as its children.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! single_value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            values . remove_all_matching ( [ ] ( Value &  value )  {  return  value . has < Operator > ( ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < NonnullOwnPtr < CalculationNode > >  value_items ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            value_items . ensure_capacity ( values . size ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            for  ( auto &  value  :  values )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( value . has < Operator > ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                value_items . unchecked_append ( move ( value . get < NonnullOwnPtr < CalculationNode > > ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            single_value  =  SumCalculationNode : : create ( move ( value_items ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 5. At this point values is a tree of Sum, Product, Negate, and Invert nodes, with other types of values at the leaf nodes. Process the leaf nodes.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //     For every leaf node leaf in values:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  parsing_failed_for_child_node  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    single_value . value ( ) - > for_each_child_node ( [ & ] ( NonnullOwnPtr < CalculationNode > &  node )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( node - > type ( )  ! =  CalculationNode : : Type : : Unparsed ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  unparsed_node  =  static_cast < UnparsedCalculationNode & > ( * node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto &  component_value  =  unparsed_node . component_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-03-31 15:10:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
										 
							
							
								        // 1. If leaf is a parenthesized simple block, replace leaf with the result of parsing a calculation from leaf’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( component_value . is_block ( )  & &  component_value . block ( ) . is_paren ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  leaf_calculation  =  parse_a_calculation ( component_value . block ( ) . values ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! leaf_calculation )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                parsing_failed_for_child_node  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            node  =  leaf_calculation . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // 2. If leaf is a math function, replace leaf with the internal representation of that math function.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: All function tokens at this point should be math functions.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        else  if  ( component_value . is_function ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto &  function  =  component_value . function ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 14:48:27 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            auto  leaf_calculation  =  parse_a_calc_function_node ( function ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-30 20:56:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! leaf_calculation )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                parsing_failed_for_child_node  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-05-30 20:56:09 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            node  =  leaf_calculation . release_nonnull ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-05-23 13:52:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        // NOTE: If we get here, then we have an UnparsedCalculationNode that didn't get replaced with something else.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        //       So, the calc() is invalid.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln_if ( CSS_PARSER_DEBUG ,  " Leftover UnparsedCalculationNode in calc tree! That probably means the syntax is invalid, but maybe we just didn't implement `{}` yet. " ,  component_value . to_debug_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        parsing_failed_for_child_node  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:20:23 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( parsing_failed_for_child_node ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-04-11 15:48:06 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: 6. Return the result of simplifying a calculation tree from values.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  single_value . release_value ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-28 16:30:59 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 00:55:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								bool  Parser : : has_ignored_vendor_prefix ( StringView  string )  
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:49:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! string . starts_with ( ' - ' ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( string . starts_with ( " -- " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:49:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( string . starts_with ( " -libweb- " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-12 16:49:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								NonnullRefPtr < StyleValue >  Parser : : resolve_unresolved_style_value ( Badge < StyleComputer > ,  ParsingContext  const &  context ,  DOM : : Element &  element ,  Optional < Selector : : PseudoElement >  pseudo_element ,  PropertyID  property_id ,  UnresolvedStyleValue  const &  unresolved )  
						 
					
						
							
								
									
										
										
										
											2022-11-02 20:25:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // Unresolved always contains a var() or attr(), unless it is a custom property's value, in which case we shouldn't be trying
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // to produce a different StyleValue from it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    VERIFY ( unresolved . contains_var_or_attr ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // If the value is invalid, we fall back to `unset`: https://www.w3.org/TR/css-variables-1/#invalid-at-computed-value-time
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-08-19 15:01:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  parser  =  MUST ( Parser : : create ( context ,  " " sv ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    return  parser . resolve_unresolved_style_value ( element ,  pseudo_element ,  property_id ,  unresolved ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-02 20:25:50 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								class  PropertyDependencyNode  :  public  RefCounted < PropertyDependencyNode >  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								public :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    static  NonnullRefPtr < PropertyDependencyNode >  create ( String  name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  adopt_ref ( * new  PropertyDependencyNode ( move ( name ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    void  add_child ( NonnullRefPtr < PropertyDependencyNode >  new_child ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto  const &  child  :  m_children )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( child - > m_name  = =  new_child - > m_name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // We detect self-reference already.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        VERIFY ( new_child - > m_name  ! =  m_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        m_children . append ( move ( new_child ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  has_cycles ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( m_marked ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        TemporaryChange  change  {  m_marked ,  true  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        for  ( auto &  child  :  m_children )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( child - > has_cycles ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								private :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    explicit  PropertyDependencyNode ( String  name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        :  m_name ( move ( name ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    String  m_name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < NonnullRefPtr < PropertyDependencyNode > >  m_children ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  m_marked  {  false  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								NonnullRefPtr < StyleValue >  Parser : : resolve_unresolved_style_value ( DOM : : Element &  element ,  Optional < Selector : : PseudoElement >  pseudo_element ,  PropertyID  property_id ,  UnresolvedStyleValue  const &  unresolved )  
						 
					
						
							
								
									
										
										
										
											2021-12-03 12:32:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  unresolved_values_without_variables_expanded  {  unresolved . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  values_with_variables_expanded ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-03 12:32:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    HashMap < FlyString ,  NonnullRefPtr < PropertyDependencyNode > >  dependencies ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! expand_variables ( element ,  pseudo_element ,  string_from_property_id ( property_id ) ,  dependencies ,  unresolved_values_without_variables_expanded ,  values_with_variables_expanded ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  UnsetStyleValue : : the ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  unresolved_values_with_variables_expanded  {  values_with_variables_expanded  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    Vector < ComponentValue >  expanded_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! expand_unresolved_values ( element ,  string_from_property_id ( property_id ) ,  unresolved_values_with_variables_expanded ,  expanded_values ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  UnsetStyleValue : : the ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  expanded_value_tokens  =  TokenStream  {  expanded_values  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( auto  parsed_value  =  parse_css_value ( property_id ,  expanded_value_tokens ) ;  ! parsed_value . is_error ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  parsed_value . release_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  UnsetStyleValue : : the ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								static  RefPtr < StyleValue  const >  get_custom_property ( DOM : : Element  const &  element ,  Optional < CSS : : Selector : : PseudoElement >  pseudo_element ,  FlyString  const &  custom_property_name )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( pseudo_element . has_value ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-05 16:19:16 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  it  =  element . custom_properties ( pseudo_element ) . find ( custom_property_name . to_string ( ) ) ;  it  ! =  element . custom_properties ( pseudo_element ) . end ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  it - > value . value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    for  ( auto  const *  current_element  =  & element ;  current_element ;  current_element  =  current_element - > parent_element ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-05 16:19:16 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  it  =  current_element - > custom_properties ( { } ) . find ( custom_property_name . to_string ( ) ) ;  it  ! =  current_element - > custom_properties ( { } ) . end ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  it - > value . value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  Parser : : expand_variables ( DOM : : Element &  element ,  Optional < Selector : : PseudoElement >  pseudo_element ,  StringView  property_name ,  HashMap < FlyString ,  NonnullRefPtr < PropertyDependencyNode > > &  dependencies ,  TokenStream < ComponentValue > &  source ,  Vector < ComponentValue > &  dest )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Arbitrary large value chosen to avoid the billion-laughs attack.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://www.w3.org/TR/css-variables-1/#long-variables
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    size_t  const  MAX_VALUE_COUNT  =  16384 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( source . remaining_token_count ( )  +  dest . size ( )  >  MAX_VALUE_COUNT )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dbgln ( " Stopped expanding CSS variables: maximum length reached. " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  get_dependency_node  =  [ & ] ( FlyString  name )  - >  NonnullRefPtr < PropertyDependencyNode >  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  existing  =  dependencies . get ( name ) ;  existing . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  * existing . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  new_node  =  PropertyDependencyNode : : create ( name . to_string ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dependencies . set ( name ,  new_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  new_node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( source . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  value  =  source . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . is_block ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  source_block  =  value . block ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < ComponentValue >  block_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  source_block_contents  {  source_block . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! expand_variables ( element ,  pseudo_element ,  property_name ,  dependencies ,  source_block_contents ,  block_values ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            NonnullRefPtr < Block >  block  =  Block : : create ( source_block . token ( ) ,  move ( block_values ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dest . empend ( block ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! value . is_function ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dest . empend ( value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! value . function ( ) . name ( ) . equals_ignoring_ascii_case ( " var " sv ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  source_function  =  value . function ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < ComponentValue >  function_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  source_function_contents  {  source_function . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! expand_variables ( element ,  pseudo_element ,  property_name ,  dependencies ,  source_function_contents ,  function_values ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            NonnullRefPtr < Function >  function  =  Function : : create ( FlyString : : from_utf8 ( source_function . name ( ) ) . release_value_but_fixme_should_propagate_errors ( ) ,  move ( function_values ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dest . empend ( function ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        TokenStream  var_contents  {  value . function ( ) . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        var_contents . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! var_contents . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  custom_property_name_token  =  var_contents . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! custom_property_name_token . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  custom_property_name  =  custom_property_name_token . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-11-07 00:22:33 +13:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! custom_property_name . bytes_as_string_view ( ) . starts_with ( " -- " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Detect dependency cycles. https://www.w3.org/TR/css-variables-1/#cycles
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // We do not do this by the spec, since we are not keeping a graph of var dependencies around,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // but rebuilding it every time.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( custom_property_name  = =  property_name ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  parent  =  get_dependency_node ( FlyString : : from_utf8 ( property_name ) . release_value_but_fixme_should_propagate_errors ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  child  =  get_dependency_node ( FlyString : : from_utf8 ( custom_property_name ) . release_value_but_fixme_should_propagate_errors ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        parent - > add_child ( child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( parent - > has_cycles ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( auto  custom_property_value  =  get_custom_property ( element ,  pseudo_element ,  FlyString : : from_utf8 ( custom_property_name ) . release_value_but_fixme_should_propagate_errors ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            VERIFY ( custom_property_value - > is_unresolved ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  custom_property_tokens  {  custom_property_value - > as_unresolved ( ) . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! expand_variables ( element ,  pseudo_element ,  custom_property_name ,  dependencies ,  custom_property_tokens ,  dest ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        // Use the provided fallback value, if any.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        var_contents . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( var_contents . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  comma_token  =  var_contents . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! comma_token . is ( Token : : Type : : Comma ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            var_contents . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! expand_variables ( element ,  pseudo_element ,  property_name ,  dependencies ,  var_contents ,  dest ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  Parser : : expand_unresolved_values ( DOM : : Element &  element ,  StringView  property_name ,  TokenStream < ComponentValue > &  source ,  Vector < ComponentValue > &  dest )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    while  ( source . has_next_token ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  const &  value  =  source . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . is_function ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( value . function ( ) . name ( ) . equals_ignoring_ascii_case ( " attr " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ! substitute_attr_function ( element ,  property_name ,  value . function ( ) ,  dest ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                    return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:16:49 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( auto  maybe_calc_value  =  parse_calculated_value ( value ) ;  maybe_calc_value  & &  maybe_calc_value - > is_calculated ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                auto &  calc_value  =  maybe_calc_value - > as_calculated ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( calc_value . resolves_to_angle ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  resolved_value  =  calc_value . resolve_angle ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( resolved_value - > to_degrees ( ) ,  " deg " _fly_string ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( calc_value . resolves_to_frequency ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  resolved_value  =  calc_value . resolve_frequency ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( resolved_value - > to_hertz ( ) ,  " hz " _fly_string ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( calc_value . resolves_to_length ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    // FIXME: In order to resolve lengths, we need to know the font metrics in case a font-relative unit
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    //  is used. So... we can't do that until style is computed?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    //  This might be easier once we have calc-simplification implemented.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( calc_value . resolves_to_percentage ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  resolved_value  =  calc_value . resolve_percentage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_percentage ( resolved_value . value ( ) . value ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( calc_value . resolves_to_time ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  resolved_value  =  calc_value . resolve_time ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( resolved_value - > to_seconds ( ) ,  " s " _fly_string ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( calc_value . resolves_to_number ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    auto  resolved_value  =  calc_value . resolve_number ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_number ( resolved_value . value ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  source_function  =  value . function ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < ComponentValue >  function_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  source_function_contents  {  source_function . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! expand_unresolved_values ( element ,  property_name ,  source_function_contents ,  function_values ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            NonnullRefPtr < Function >  function  =  Function : : create ( source_function . name ( ) ,  move ( function_values ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dest . empend ( function ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( value . is_block ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  const &  source_block  =  value . block ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            TokenStream  source_block_values  {  source_block . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            Vector < ComponentValue >  block_values ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! expand_unresolved_values ( element ,  property_name ,  source_block_values ,  block_values ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            NonnullRefPtr < Block >  block  =  Block : : create ( source_block . token ( ) ,  move ( block_values ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dest . empend ( move ( block ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        dest . empend ( value . token ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-03 12:32:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								// https://drafts.csswg.org/css-values-5/#attr-substitution
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								bool  Parser : : substitute_attr_function ( DOM : : Element &  element ,  StringView  property_name ,  Function  const &  attr_function ,  Vector < ComponentValue > &  dest )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // First, parse the arguments to attr():
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // attr() = attr( <q-name> <attr-type>? , <declaration-value>?)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // <attr-type> = string | url | ident | color | number | percentage | length | angle | time | frequency | flex | <dimension-unit>
 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    TokenStream  attr_contents  {  attr_function . values ( )  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    attr_contents . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! attr_contents . has_next_token ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // - Attribute name
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // FIXME: Support optional attribute namespace
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( ! attr_contents . peek_token ( ) . is ( Token : : Type : : Ident ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    auto  attribute_name  =  attr_contents . next_token ( ) . token ( ) . ident ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    attr_contents . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // - Attribute type (optional)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    auto  attribute_type  =  " string " _fly_string ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( attr_contents . peek_token ( ) . is ( Token : : Type : : Ident ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        attribute_type  =  MUST ( FlyString : : from_utf8 ( attr_contents . next_token ( ) . token ( ) . ident ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        attr_contents . skip_whitespace ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // - Comma, then fallback values (optional)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    bool  has_fallback_values  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( attr_contents . has_next_token ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( ! attr_contents . peek_token ( ) . is ( Token : : Type : : Comma ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								            return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        ( void ) attr_contents . next_token ( ) ;  // Comma
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        has_fallback_values  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // Then, run the substitution algorithm:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // 1. If the attr() function has a substitution value, replace the attr() function by the substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    // https://drafts.csswg.org/css-values-5/#attr-types
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( element . has_attribute ( attribute_name ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        auto  attribute_value  =  element . get_attribute_value ( attribute_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        if  ( attribute_type . equals_ignoring_ascii_case ( " angle " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the result is a <dimension-token> whose unit matches the given type, the result is the substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( )  & &  component_value - > is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( Angle : : unit_from_name ( component_value - > token ( ) . dimension_unit ( ) ) . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . append ( component_value . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " color " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the result is a <hex-color> or a named color ident, the substitution value is that result as a <color>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( ( component_value - > is ( Token : : Type : : Hash ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        & &  Color : : from_string ( MUST ( String : : formatted ( " #{} " ,  component_value - > token ( ) . hash_value ( ) ) ) ) . has_value ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    | |  ( component_value - > is ( Token : : Type : : Ident ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                        & &  Color : : from_string ( component_value - > token ( ) . ident ( ) ) . has_value ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . append ( component_value . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 14:48:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " flex " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the result is a <dimension-token> whose unit matches the given type, the result is the substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( )  & &  component_value - > is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( Flex : : unit_from_name ( component_value - > token ( ) . dimension_unit ( ) ) . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . append ( component_value . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " frequency " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the result is a <dimension-token> whose unit matches the given type, the result is the substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( )  & &  component_value - > is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( Frequency : : unit_from_name ( component_value - > token ( ) . dimension_unit ( ) ) . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . append ( component_value . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " ident " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // The substitution value is a CSS <custom-ident>, whose value is the literal value of the attribute,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // with leading and trailing ASCII whitespace stripped. (No CSS parsing of the value is performed.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the attribute value, after trimming, is the empty string, there is instead no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // If the <custom-ident>’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  substitution_value  =  attribute_value . trim_whitespace ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( ! substitution_value . is_empty ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                & &  ! substitution_value . equals_ignoring_ascii_case ( " default " sv ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                & &  ! is_css_wide_keyword ( substitution_value ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dest . empend ( Token : : create_ident ( MUST ( FlyString : : from_deprecated_fly_string ( substitution_value ) ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " length " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the result is a <dimension-token> whose unit matches the given type, the result is the substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( )  & &  component_value - > is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( Length : : unit_from_name ( component_value - > token ( ) . dimension_unit ( ) ) . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . append ( component_value . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " number " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the result is a <number-token>, the result is the substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( )  & &  component_value - > is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dest . append ( component_value . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " percentage " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the result is a <percentage-token>, the result is the substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( )  & &  component_value - > is ( Token : : Type : : Percentage ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                dest . append ( component_value . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " string " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // The substitution value is a CSS string, whose value is the literal value of the attribute.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // (No CSS parsing or "cleanup" of the value is performed.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // No value triggers fallback.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dest . empend ( Token : : create_string ( MUST ( FlyString : : from_deprecated_fly_string ( attribute_value ) ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " time " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // If the result is a <dimension-token> whose unit matches the given type, the result is the substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( )  & &  component_value - > is ( Token : : Type : : Dimension ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( Time : : unit_from_name ( component_value - > token ( ) . dimension_unit ( ) ) . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . append ( component_value . release_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  if  ( attribute_type . equals_ignoring_ascii_case ( " url " _fly_string ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // The substitution value is a CSS <url> value, whose url is the literal value of the attribute.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // (No CSS parsing or "cleanup" of the value is performed.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // No value triggers fallback.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            dest . empend ( Token : : create_url ( MUST ( FlyString : : from_deprecated_fly_string ( attribute_value ) ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Dimension units
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // Parse a component value from the attribute’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								            // If the result is a <number-token>, the substitution value is a dimension with the result’  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            // Otherwise, there is no substitution value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            auto  component_value  =  MUST ( Parser : : Parser : : create ( m_context ,  attribute_value ) ) . parse_as_component_value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            if  ( component_value . has_value ( )  & &  component_value - > is ( Token : : Type : : Number ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                if  ( attribute_value  = =  " % " sv )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( component_value - > token ( ) . number_value ( ) ,  attribute_type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( auto  angle_unit  =  Angle : : unit_from_name ( attribute_type ) ;  angle_unit . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( component_value - > token ( ) . number_value ( ) ,  attribute_type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-28 14:48:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( auto  flex_unit  =  Flex : : unit_from_name ( attribute_type ) ;  flex_unit . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( component_value - > token ( ) . number_value ( ) ,  attribute_type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( auto  frequency_unit  =  Frequency : : unit_from_name ( attribute_type ) ;  frequency_unit . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( component_value - > token ( ) . number_value ( ) ,  attribute_type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( auto  length_unit  =  Length : : unit_from_name ( attribute_type ) ;  length_unit . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( component_value - > token ( ) . number_value ( ) ,  attribute_type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  if  ( auto  time_unit  =  Time : : unit_from_name ( attribute_type ) ;  time_unit . has_value ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    dest . empend ( Token : : create_dimension ( component_value - > token ( ) . number_value ( ) ,  attribute_type ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    // Not a dimension unit.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 12:57:12 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 2. Otherwise, if the attr() function has a fallback value as its last argument, replace the attr() function by the fallback value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    //    If there are any var() or attr() references in the fallback, substitute them as well.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    if  ( has_fallback_values ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								        return  expand_unresolved_values ( element ,  property_name ,  attr_contents ,  dest ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-04 11:34:22 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								    // 3. Otherwise, the property containing the attr() function is invalid at computed-value time.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-03-22 17:41:47 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								}