SVGSVGElement.cpp 1003 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibGfx/Painter.h>
  7. #include <LibWeb/CSS/StyleResolver.h>
  8. #include <LibWeb/DOM/Document.h>
  9. #include <LibWeb/DOM/Event.h>
  10. #include <LibWeb/Layout/SVGSVGBox.h>
  11. #include <LibWeb/SVG/SVGSVGElement.h>
  12. namespace Web::SVG {
  13. SVGSVGElement::SVGSVGElement(DOM::Document& document, QualifiedName qualified_name)
  14. : SVGGraphicsElement(document, qualified_name)
  15. {
  16. }
  17. RefPtr<Layout::Node> SVGSVGElement::create_layout_node()
  18. {
  19. auto style = document().style_resolver().resolve_style(*this);
  20. if (style->display() == CSS::Display::None)
  21. return nullptr;
  22. return adopt_ref(*new Layout::SVGSVGBox(document(), *this, move(style)));
  23. }
  24. unsigned SVGSVGElement::width() const
  25. {
  26. return attribute(HTML::AttributeNames::width).to_uint().value_or(300);
  27. }
  28. unsigned SVGSVGElement::height() const
  29. {
  30. return attribute(HTML::AttributeNames::height).to_uint().value_or(150);
  31. }
  32. }