SVGGraphicsElement.cpp 860 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/SVG/SVGGraphicsElement.h>
  7. namespace Web::SVG {
  8. SVGGraphicsElement::SVGGraphicsElement(DOM::Document& document, QualifiedName qualified_name)
  9. : SVGElement(document, move(qualified_name))
  10. {
  11. }
  12. void SVGGraphicsElement::parse_attribute(const FlyString& name, const String& value)
  13. {
  14. SVGElement::parse_attribute(name, value);
  15. if (name == "fill") {
  16. m_fill_color = Gfx::Color::from_string(value).value_or(Color::Transparent);
  17. } else if (name == "stroke") {
  18. m_stroke_color = Gfx::Color::from_string(value).value_or(Color::Transparent);
  19. } else if (name == "stroke-width") {
  20. auto result = value.to_int();
  21. if (result.has_value())
  22. m_stroke_width = result.value();
  23. }
  24. }
  25. }