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.
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			761 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			761 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibWeb/SVG/AttributeParser.h>
 | |
| #include <LibWeb/SVG/SVGGraphicsElement.h>
 | |
| #include <LibWeb/WebIDL/ExceptionOr.h>
 | |
| 
 | |
| namespace Web::SVG {
 | |
| 
 | |
| // https://svgwg.org/svg2-draft/text.html#InterfaceSVGTextContentElement
 | |
| class SVGTextContentElement : public SVGGraphicsElement {
 | |
|     WEB_PLATFORM_OBJECT(SVGTextContentElement, SVGGraphicsElement);
 | |
| 
 | |
| public:
 | |
|     WebIDL::ExceptionOr<int> get_number_of_chars() const;
 | |
| 
 | |
|     Optional<TextAnchor> text_anchor() const;
 | |
| 
 | |
|     DeprecatedString text_contents() const;
 | |
| 
 | |
| protected:
 | |
|     SVGTextContentElement(DOM::Document&, DOM::QualifiedName);
 | |
| 
 | |
|     virtual void initialize(JS::Realm&) override;
 | |
| };
 | |
| 
 | |
| }
 |