mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 08:02:44 +00:00 
			
		
		
		
	LibWeb: Turn <td align> into CSS text-align
Note that align=center and align=middle both behave like the <center> element, and not like text-align:center.
This commit is contained in:
		
							parent
							
								
									07ccaa1934
								
							
						
					
					
						commit
						7e8945601a
					
				
					 4 changed files with 15 additions and 0 deletions
				
			
		|  | @ -55,6 +55,11 @@ void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue> | ||||||
|     m_property_values.set((unsigned)id, move(value)); |     m_property_values.set((unsigned)id, move(value)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void StyleProperties::set_property(CSS::PropertyID id, const StringView& value) | ||||||
|  | { | ||||||
|  |     m_property_values.set((unsigned)id, StringStyleValue::create(value)); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| Optional<NonnullRefPtr<StyleValue>> StyleProperties::property(CSS::PropertyID id) const | Optional<NonnullRefPtr<StyleValue>> StyleProperties::property(CSS::PropertyID id) const | ||||||
| { | { | ||||||
|     auto it = m_property_values.find((unsigned)id); |     auto it = m_property_values.find((unsigned)id); | ||||||
|  |  | ||||||
|  | @ -52,6 +52,7 @@ public: | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void set_property(CSS::PropertyID, NonnullRefPtr<StyleValue> value); |     void set_property(CSS::PropertyID, NonnullRefPtr<StyleValue> value); | ||||||
|  |     void set_property(CSS::PropertyID, const StringView&); | ||||||
|     Optional<NonnullRefPtr<StyleValue>> property(CSS::PropertyID) const; |     Optional<NonnullRefPtr<StyleValue>> property(CSS::PropertyID) const; | ||||||
| 
 | 
 | ||||||
|     Length length_or_fallback(CSS::PropertyID, const Length& fallback) const; |     Length length_or_fallback(CSS::PropertyID, const Length& fallback) const; | ||||||
|  |  | ||||||
|  | @ -55,6 +55,7 @@ void initialize(); | ||||||
|     __ENUMERATE_HTML_ATTRIBUTE(defer)   \ |     __ENUMERATE_HTML_ATTRIBUTE(defer)   \ | ||||||
|     __ENUMERATE_HTML_ATTRIBUTE(bgcolor) \ |     __ENUMERATE_HTML_ATTRIBUTE(bgcolor) \ | ||||||
|     __ENUMERATE_HTML_ATTRIBUTE(size)    \ |     __ENUMERATE_HTML_ATTRIBUTE(size)    \ | ||||||
|  |     __ENUMERATE_HTML_ATTRIBUTE(align)   \ | ||||||
|     __ENUMERATE_HTML_ATTRIBUTE(colspan) |     __ENUMERATE_HTML_ATTRIBUTE(colspan) | ||||||
| 
 | 
 | ||||||
| #define __ENUMERATE_HTML_ATTRIBUTE(name) extern FlyString name; | #define __ENUMERATE_HTML_ATTRIBUTE(name) extern FlyString name; | ||||||
|  |  | ||||||
|  | @ -44,6 +44,14 @@ void HTMLTableCellElement::apply_presentational_hints(StyleProperties& style) co | ||||||
|             auto color = Color::from_string(value); |             auto color = Color::from_string(value); | ||||||
|             if (color.has_value()) |             if (color.has_value()) | ||||||
|                 style.set_property(CSS::PropertyID::BackgroundColor, ColorStyleValue::create(color.value())); |                 style.set_property(CSS::PropertyID::BackgroundColor, ColorStyleValue::create(color.value())); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |         if (name == HTML::AttributeNames::align) { | ||||||
|  |             if (value.equals_ignoring_case("center") || value.equals_ignoring_case("middle")) | ||||||
|  |                 style.set_property(CSS::PropertyID::TextAlign, StringView("-libweb-center")); | ||||||
|  |             else | ||||||
|  |                 style.set_property(CSS::PropertyID::TextAlign, value.view()); | ||||||
|  |             return; | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling