summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/SVGGraphicsBox.cpp
blob: 95149b84a0074fca6f1dedc384bf759e81782f81 (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
32
/*
 * Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibWeb/Layout/SVGGraphicsBox.h>

namespace Web::Layout {

SVGGraphicsBox::SVGGraphicsBox(DOM::Document& document, SVG::SVGGraphicsElement& element, NonnullRefPtr<CSS::StyleProperties> properties)
    : SVGBox(document, element, properties)
{
}

void SVGGraphicsBox::before_children_paint(PaintContext& context, PaintPhase phase)
{
    SVGBox::before_children_paint(context, phase);
    if (phase != PaintPhase::Foreground)
        return;

    auto& graphics_element = downcast<SVG::SVGGraphicsElement>(dom_node());

    if (graphics_element.fill_color().has_value())
        context.svg_context().set_fill_color(graphics_element.fill_color().value());
    if (graphics_element.stroke_color().has_value())
        context.svg_context().set_stroke_color(graphics_element.stroke_color().value());
    if (graphics_element.stroke_width().has_value())
        context.svg_context().set_stroke_width(graphics_element.stroke_width().value());
}

}