summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp
blob: 4a407b616cecac747576c7a45a55f9c705612893 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibWeb/SVG/SVGGraphicsElement.h>

namespace Web::SVG {

SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, QualifiedName qualified_name)
    : SVGElement(document, move(qualified_name))
{
}

void SVGGraphicsElement::parse_attribute(const FlyString& name, const String& value)
{
    SVGElement::parse_attribute(name, value);

    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();
    }
}

}