mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:52:44 +00:00 
			
		
		
		
	 4c5d48f861
			
		
	
	
		4c5d48f861
		
	
	
	
	
		
			
			This makes use of the new Gfx::Path::text() to handle SVG text elements, with this text is just a regular path, and can be manipulated like any other graphics element. This removes the SVGTextPaintable and makes both <text> and geometry elements use a new (shared) SVGPathPaintable. This is identical to the old SVGGeometryPaintable. This simplifies painting as once something is resolved to a Gfx::Path, the painting logic is the same.
		
			
				
	
	
		
			39 lines
		
	
	
	
		
			960 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
	
		
			960 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibWeb/Layout/SVGGraphicsBox.h>
 | |
| #include <LibWeb/Painting/SVGGraphicsPaintable.h>
 | |
| 
 | |
| namespace Web::Painting {
 | |
| 
 | |
| class SVGPathPaintable final : public SVGGraphicsPaintable {
 | |
|     JS_CELL(SVGPathPaintable, SVGGraphicsPaintable);
 | |
| 
 | |
| public:
 | |
|     static JS::NonnullGCPtr<SVGPathPaintable> create(Layout::SVGGraphicsBox const&);
 | |
| 
 | |
|     virtual Optional<HitTestResult> hit_test(CSSPixelPoint, HitTestType) const override;
 | |
| 
 | |
|     virtual void paint(PaintContext&, PaintPhase) const override;
 | |
| 
 | |
|     Layout::SVGGraphicsBox const& layout_box() const;
 | |
| 
 | |
|     void set_computed_path(Gfx::Path path)
 | |
|     {
 | |
|         m_computed_path = move(path);
 | |
|     }
 | |
| 
 | |
|     Optional<Gfx::Path> const& computed_path() const { return m_computed_path; }
 | |
| 
 | |
| protected:
 | |
|     SVGPathPaintable(Layout::SVGGraphicsBox const&);
 | |
| 
 | |
|     Optional<Gfx::Path> m_computed_path = {};
 | |
| };
 | |
| 
 | |
| }
 |