LibWeb: Add SVGFormattingContext to handle SVG box trees

Instead of trying to layout SVG boxes as if they are regular CSS boxes,
let's invent an "SVG formatting context" and let it manage SVG boxes.

To facilitate this, Layout::SVGBox no longer inherits from ReplacedBox,
and is instead a simple, "inline-block" style BlockBox.
This commit is contained in:
Andreas Kling 2021-09-17 23:12:16 +02:00
commit 92c08ad4ac
Notes: sideshowbarker 2024-07-18 03:44:41 +09:00
11 changed files with 65 additions and 26 deletions

View file

@ -11,6 +11,8 @@
#include <LibWeb/Layout/FormattingContext.h>
#include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Layout/SVGFormattingContext.h>
#include <LibWeb/Layout/SVGSVGBox.h>
#include <LibWeb/Layout/TableBox.h>
#include <LibWeb/Layout/TableCellBox.h>
#include <LibWeb/Layout/TableFormattingContext.h>
@ -67,6 +69,12 @@ bool FormattingContext::creates_block_formatting_context(const Box& box)
void FormattingContext::layout_inside(Box& box, LayoutMode layout_mode)
{
if (is<SVGSVGBox>(box)) {
SVGFormattingContext context(box, this);
context.run(box, layout_mode);
return;
}
if (creates_block_formatting_context(box)) {
BlockFormattingContext context(box, this);
context.run(box, layout_mode);