mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:32:45 +00:00 
			
		
		
		
	LibWeb: Add a dedicated function for parsing HTML length values
Presentation attribute lengths (width, height, etc.) can always be unit-less (e.g "400") so going via the normal CSS parsing path only works when the document is in quirks mode. Add a separate parse_html_length() that always allows unit-less values.
This commit is contained in:
		
							parent
							
								
									9fc00d5d12
								
							
						
					
					
						commit
						5a7e57457e
					
				
					 4 changed files with 12 additions and 2 deletions
				
			
		|  | @ -928,4 +928,12 @@ RefPtr<StyleDeclaration> parse_css_declaration(const CSS::ParsingContext& contex | |||
|     return parser.parse_standalone_declaration(); | ||||
| } | ||||
| 
 | ||||
| RefPtr<StyleValue> parse_html_length(const Document& document, const StringView& string) | ||||
| { | ||||
|     auto integer = string.to_int(); | ||||
|     if (integer.has_value()) | ||||
|         return LengthStyleValue::create(Length::make_px(integer.value())); | ||||
|     return parse_css_value(CSS::ParsingContext(document), string); | ||||
| } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling