mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-04 07:10:57 +00:00 
			
		
		
		
	LibWeb: Generalize support for dimension attributes
Rather than each element which supports dimension attributes needing to implement parsing the attributes and setting the appropriate style, we can generalize this functionality. This will also make each element more closely resemble the spec text, as we will be effectively declaring, for example, "The img element supports dimension attributes" in code.
This commit is contained in:
		
							parent
							
								
									058dd225dd
								
							
						
					
					
						commit
						4b1abcf61d
					
				
				
				Notes:
				
					sideshowbarker
				
				2024-07-17 00:59:43 +09:00 
				
			
			Author: https://github.com/trflynn89
Commit: 4b1abcf61d
Pull-request: https://github.com/SerenityOS/serenity/pull/23928
Issue: https://github.com/SerenityOS/serenity/issues/23926
Reviewed-by: https://github.com/AtkinsSJ
			
					 8 changed files with 32 additions and 42 deletions
				
			
		| 
						 | 
				
			
			@ -1525,24 +1525,6 @@ i32 HTMLInputElement::default_tab_index_value() const
 | 
			
		|||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):the-input-element-11
 | 
			
		||||
void HTMLInputElement::apply_presentational_hints(CSS::StyleProperties& style) const
 | 
			
		||||
{
 | 
			
		||||
    // The input element supports dimension attributes.
 | 
			
		||||
    if (type_state() != TypeAttributeState::ImageButton)
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    for_each_attribute([&](auto& name, auto& value) {
 | 
			
		||||
        if (name == HTML::AttributeNames::width) {
 | 
			
		||||
            if (auto parsed_value = parse_dimension_value(value))
 | 
			
		||||
                style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
 | 
			
		||||
        } else if (name == HTML::AttributeNames::height) {
 | 
			
		||||
            if (auto parsed_value = parse_dimension_value(value))
 | 
			
		||||
                style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//  https://html.spec.whatwg.org/multipage/input.html#dom-input-maxlength
 | 
			
		||||
WebIDL::Long HTMLInputElement::max_length() const
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue