mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 22:02:44 +00:00 
			
		
		
		
	 c93d367d95
			
		
	
	
		c93d367d95
		
	
	
	
	
		
			
			Previously, all SVG <text> elements were zero-sized boxes, that were only actually positioned and sized during painting. This led to a number of problems, the most visible of which being that text could not be scaled based on the viewBox. Which this patch, <text> elements get a correctly sized layout box, that can be hit-tested and respects the SVG viewBox. To share code with SVGGeometryElement's the PathData (from the prior commit) has been split into a computed path and computed transforms. The computed path is specific to geometry elements, but the computed transforms are shared between all SVG graphics elements.
		
			
				
	
	
		
			31 lines
		
	
	
	
		
			949 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
	
		
			949 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/Optional.h>
 | |
| #include <LibWeb/Layout/SVGGraphicsBox.h>
 | |
| #include <LibWeb/SVG/SVGTextPositioningElement.h>
 | |
| 
 | |
| namespace Web::Layout {
 | |
| 
 | |
| class SVGTextBox final : public SVGGraphicsBox {
 | |
|     JS_CELL(SVGTextBox, SVGGraphicsBox);
 | |
| 
 | |
| public:
 | |
|     SVGTextBox(DOM::Document&, SVG::SVGTextPositioningElement&, NonnullRefPtr<CSS::StyleProperties>);
 | |
|     virtual ~SVGTextBox() override = default;
 | |
| 
 | |
|     SVG::SVGTextPositioningElement& dom_node() { return static_cast<SVG::SVGTextPositioningElement&>(SVGGraphicsBox::dom_node()); }
 | |
|     SVG::SVGTextPositioningElement const& dom_node() const { return static_cast<SVG::SVGTextPositioningElement const&>(SVGGraphicsBox::dom_node()); }
 | |
| 
 | |
|     virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
 | |
| 
 | |
| private:
 | |
|     CSSPixelPoint viewbox_origin() const;
 | |
| };
 | |
| 
 | |
| }
 |