2020-07-22 15:17:39 -07:00
|
|
|
/*
|
2021-04-22 16:53:07 -07:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2020-07-22 15:17:39 -07:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-22 15:17:39 -07:00
|
|
|
*/
|
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
2020-07-22 15:17:39 -07:00
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
namespace Web::SVG {
|
2020-07-22 15:17:39 -07:00
|
|
|
|
2021-02-07 11:20:15 +01:00
|
|
|
SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, QualifiedName qualified_name)
|
|
|
|
: SVGElement(document, move(qualified_name))
|
2020-07-22 15:17:39 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
void SVGGraphicsElement::parse_attribute(const FlyString& name, const String& value)
|
2020-07-22 15:17:39 -07:00
|
|
|
{
|
2020-07-23 09:44:42 -07:00
|
|
|
SVGElement::parse_attribute(name, value);
|
2020-07-22 15:17:39 -07:00
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
if (name == "fill") {
|
|
|
|
m_fill_color = Gfx::Color::from_string(value).value_or(Color::Transparent);
|
|
|
|
} else if (name == "stroke") {
|
|
|
|
m_stroke_color = Gfx::Color::from_string(value).value_or(Color::Transparent);
|
|
|
|
} else if (name == "stroke-width") {
|
|
|
|
auto result = value.to_int();
|
|
|
|
if (result.has_value())
|
|
|
|
m_stroke_width = result.value();
|
|
|
|
}
|
2020-07-22 15:17:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|