mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
LibWeb: Implement very naive layout of <path> within <svg>
This commit is contained in:
parent
7ac889e533
commit
684f7cca9f
1 changed files with 21 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/Format.h>
|
||||
#include <LibWeb/Layout/SVGFormattingContext.h>
|
||||
#include <LibWeb/Layout/SVGPathBox.h>
|
||||
#include <LibWeb/Layout/SVGSVGBox.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
@ -19,8 +20,27 @@ SVGFormattingContext::~SVGFormattingContext()
|
|||
{
|
||||
}
|
||||
|
||||
void SVGFormattingContext::run(Box&, LayoutMode)
|
||||
void SVGFormattingContext::run(Box& box, LayoutMode)
|
||||
{
|
||||
// FIXME: This formatting context is basically a total hack.
|
||||
// It works by computing the united bounding box of all <path>'s
|
||||
// within an <svg>, and using that as the size of this box.
|
||||
|
||||
Gfx::FloatRect total_bounding_box;
|
||||
|
||||
box.for_each_in_subtree_of_type<SVGBox>([&](auto& descendant) {
|
||||
if (is<SVGPathBox>(descendant)) {
|
||||
auto& path_box = static_cast<SVGPathBox&>(descendant);
|
||||
auto& path = path_box.dom_node().get_path();
|
||||
path_box.set_size(path.bounding_box().size());
|
||||
|
||||
total_bounding_box = total_bounding_box.united(path.bounding_box());
|
||||
}
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
box.set_size(total_bounding_box.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue