mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
LibWeb: Layout SVG <text> elements during layout (not while painting)
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.
This commit is contained in:
parent
dc9cb449b1
commit
c93d367d95
16 changed files with 209 additions and 173 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <LibWeb/Layout/LayoutState.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/SVGGeometryPaintable.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -266,9 +267,14 @@ void LayoutState::commit(Box& root)
|
|||
paintables_with_lines.append(paintable_with_lines);
|
||||
}
|
||||
|
||||
if (used_values.svg_path_data().has_value() && is<Painting::SVGGeometryPaintable>(paintable_box)) {
|
||||
if (used_values.computed_svg_transforms().has_value() && is<Painting::SVGGraphicsPaintable>(paintable_box)) {
|
||||
auto& svg_graphics_paintable = static_cast<Painting::SVGGraphicsPaintable&>(paintable_box);
|
||||
svg_graphics_paintable.set_computed_transforms(*used_values.computed_svg_transforms());
|
||||
}
|
||||
|
||||
if (used_values.computed_svg_path().has_value() && is<Painting::SVGGeometryPaintable>(paintable_box)) {
|
||||
auto& svg_geometry_paintable = static_cast<Painting::SVGGeometryPaintable&>(paintable_box);
|
||||
svg_geometry_paintable.set_path_data(move(*used_values.svg_path_data()));
|
||||
svg_geometry_paintable.set_computed_path(move(*used_values.computed_svg_path()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue