
Previously, we were handling viewBoxes/viewports in a slightly hacky way, asking graphics elements to figure out what viewBox to use during layout. This does not work in all cases, and can't allow for more complex SVGs where it is possible to have nested viewports. This commit makes the SVGFormattingContext keep track of the viewport/boxes, and it now lays out each viewport recursively, where each nested `<svg>` or `<symbol>` can establish a new viewport. This fixes some previous edge cases, and starts to allow nested viewports (there's still some issues to resolve there). Fixes #22931
27 lines
738 B
C++
27 lines
738 B
C++
/*
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/Layout/FormattingContext.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class SVGFormattingContext : public FormattingContext {
|
|
public:
|
|
explicit SVGFormattingContext(LayoutState&, Box const&, FormattingContext* parent, Gfx::AffineTransform parent_viewbox_transform = {});
|
|
~SVGFormattingContext();
|
|
|
|
virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
|
|
virtual CSSPixels automatic_content_width() const override;
|
|
virtual CSSPixels automatic_content_height() const override;
|
|
|
|
private:
|
|
Gfx::AffineTransform m_parent_viewbox_transform {};
|
|
};
|
|
|
|
}
|