mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
LibWeb: Implement painting for svg text
The implementation of painting for SVG text follows the same pattern as the implementation of painting for SVG geometries. However, instead of reusing the existing PaintableWithLines to draw text, a new class called SVGTextPaintable is introduced. because everything that is painted inside an SVG is expected to inherit from SVGGraphicsPaintable. Therefore reusing the text painting from regular text nodes would require significant refactoring.
This commit is contained in:
parent
81a6976e90
commit
0d8d7ae94e
9 changed files with 216 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <LibWeb/Layout/SVGFormattingContext.h>
|
||||
#include <LibWeb/Layout/SVGGeometryBox.h>
|
||||
#include <LibWeb/Layout/SVGSVGBox.h>
|
||||
#include <LibWeb/Layout/SVGTextBox.h>
|
||||
#include <LibWeb/SVG/SVGForeignObjectElement.h>
|
||||
#include <LibWeb/SVG/SVGSVGElement.h>
|
||||
|
||||
|
@ -187,6 +188,10 @@ void SVGFormattingContext::run(Box const& box, LayoutMode layout_mode, Available
|
|||
} else if (is<SVGSVGBox>(descendant)) {
|
||||
SVGFormattingContext nested_context(m_state, descendant, this);
|
||||
nested_context.run(descendant, layout_mode, available_space);
|
||||
} else if (is<SVGTextBox>(descendant)) {
|
||||
auto const& svg_text_box = static_cast<SVGTextBox const&>(descendant);
|
||||
// NOTE: This hack creates a layout state to ensure the existence of a paintable box node in LayoutState::commit(), even when none of the values from UsedValues impact the SVG text.
|
||||
m_state.get_mutable(svg_text_box);
|
||||
}
|
||||
|
||||
return IterationDecision::Continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue