mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:52:43 +00:00 
			
		
		
		
	LibWeb: Update SVG get_path() API to take a viewport size
				
					
				
			This will allow resolving paths that use sizes that are relative to the viewport. This necessarily removes the on element caching, which has been redundant for a while as computed paths are stored on the paintable.
This commit is contained in:
		
							parent
							
								
									1fbf1073ab
								
							
						
					
					
						commit
						b9afea40e6
					
				
					 16 changed files with 55 additions and 126 deletions
				
			
		|  | @ -30,24 +30,17 @@ void SVGEllipseElement::attribute_changed(FlyString const& name, Optional<String | |||
| 
 | ||||
|     if (name == SVG::AttributeNames::cx) { | ||||
|         m_center_x = AttributeParser::parse_coordinate(value.value_or(String {})); | ||||
|         m_path.clear(); | ||||
|     } else if (name == SVG::AttributeNames::cy) { | ||||
|         m_center_y = AttributeParser::parse_coordinate(value.value_or(String {})); | ||||
|         m_path.clear(); | ||||
|     } else if (name == SVG::AttributeNames::rx) { | ||||
|         m_radius_x = AttributeParser::parse_positive_length(value.value_or(String {})); | ||||
|         m_path.clear(); | ||||
|     } else if (name == SVG::AttributeNames::ry) { | ||||
|         m_radius_y = AttributeParser::parse_positive_length(value.value_or(String {})); | ||||
|         m_path.clear(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| Gfx::Path& SVGEllipseElement::get_path() | ||||
| Gfx::Path SVGEllipseElement::get_path(CSSPixelSize) | ||||
| { | ||||
|     if (m_path.has_value()) | ||||
|         return m_path.value(); | ||||
| 
 | ||||
|     float rx = m_radius_x.value_or(0); | ||||
|     float ry = m_radius_y.value_or(0); | ||||
|     float cx = m_center_x.value_or(0); | ||||
|  | @ -55,10 +48,8 @@ Gfx::Path& SVGEllipseElement::get_path() | |||
|     Gfx::Path path; | ||||
| 
 | ||||
|     // A computed value of zero for either dimension, or a computed value of auto for both dimensions, disables rendering of the element.
 | ||||
|     if (rx == 0 || ry == 0) { | ||||
|         m_path = move(path); | ||||
|         return m_path.value(); | ||||
|     } | ||||
|     if (rx == 0 || ry == 0) | ||||
|         return path; | ||||
| 
 | ||||
|     Gfx::FloatSize radii = { rx, ry }; | ||||
|     double x_axis_rotation = 0; | ||||
|  | @ -80,8 +71,7 @@ Gfx::Path& SVGEllipseElement::get_path() | |||
|     // 5. arc with a segment-completing close path operation.
 | ||||
|     path.elliptical_arc_to({ cx + rx, cy }, radii, x_axis_rotation, large_arc, sweep); | ||||
| 
 | ||||
|     m_path = move(path); | ||||
|     return m_path.value(); | ||||
|     return path; | ||||
| } | ||||
| 
 | ||||
| // https://www.w3.org/TR/SVG11/shapes.html#EllipseElementCXAttribute
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 MacDue
						MacDue