2020-07-19 23:01:53 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-19 23:01:53 -07:00
|
|
|
*/
|
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
#include <LibGfx/Painter.h>
|
2020-07-19 23:01:53 -07:00
|
|
|
#include <LibWeb/CSS/StyleResolver.h>
|
|
|
|
#include <LibWeb/DOM/Document.h>
|
|
|
|
#include <LibWeb/DOM/Event.h>
|
2020-11-22 15:53:01 +01:00
|
|
|
#include <LibWeb/Layout/SVGSVGBox.h>
|
2021-09-15 01:12:41 +02:00
|
|
|
#include <LibWeb/SVG/AttributeNames.h>
|
2020-07-23 09:44:42 -07:00
|
|
|
#include <LibWeb/SVG/SVGSVGElement.h>
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
namespace Web::SVG {
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2021-02-07 11:20:15 +01:00
|
|
|
SVGSVGElement::SVGSVGElement(DOM::Document& document, QualifiedName qualified_name)
|
2020-10-10 02:48:05 +01:00
|
|
|
: SVGGraphicsElement(document, qualified_name)
|
2020-07-19 23:01:53 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-06 14:27:40 +01:00
|
|
|
RefPtr<Layout::Node> SVGSVGElement::create_layout_node()
|
2020-07-19 23:01:53 -07:00
|
|
|
{
|
2021-01-06 14:27:40 +01:00
|
|
|
auto style = document().style_resolver().resolve_style(*this);
|
2020-07-19 23:01:53 -07:00
|
|
|
if (style->display() == CSS::Display::None)
|
|
|
|
return nullptr;
|
2021-04-23 16:46:57 +02:00
|
|
|
return adopt_ref(*new Layout::SVGSVGBox(document(), *this, move(style)));
|
2020-07-19 23:01:53 -07:00
|
|
|
}
|
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
unsigned SVGSVGElement::width() const
|
2020-07-19 23:01:53 -07:00
|
|
|
{
|
|
|
|
return attribute(HTML::AttributeNames::width).to_uint().value_or(300);
|
|
|
|
}
|
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
unsigned SVGSVGElement::height() const
|
2020-07-19 23:01:53 -07:00
|
|
|
{
|
|
|
|
return attribute(HTML::AttributeNames::height).to_uint().value_or(150);
|
|
|
|
}
|
|
|
|
|
2021-09-15 01:12:41 +02:00
|
|
|
void SVGSVGElement::parse_attribute(FlyString const& name, String const& value)
|
|
|
|
{
|
|
|
|
SVGGraphicsElement::parse_attribute(name, value);
|
|
|
|
|
|
|
|
if (name.equals_ignoring_case(SVG::AttributeNames::viewBox))
|
|
|
|
m_view_box = try_parse_view_box(value);
|
|
|
|
}
|
|
|
|
|
2020-07-19 23:01:53 -07:00
|
|
|
}
|