SVGStopElement.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2023, MacDue <macdue@dueutil.tech>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGfx/Color.h>
  8. #include <LibWeb/SVG/AttributeParser.h>
  9. #include <LibWeb/SVG/SVGAnimatedNumber.h>
  10. #include <LibWeb/SVG/SVGElement.h>
  11. namespace Web::SVG {
  12. class SVGStopElement final : public SVGElement {
  13. WEB_PLATFORM_OBJECT(SVGStopElement, SVGElement);
  14. public:
  15. virtual ~SVGStopElement() override = default;
  16. virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  17. JS::NonnullGCPtr<SVGAnimatedNumber> offset() const;
  18. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  19. NumberPercentage stop_offset() const { return m_offset.value_or(NumberPercentage::create_number(0)); }
  20. Gfx::Color stop_color() const;
  21. private:
  22. SVGStopElement(DOM::Document&, DOM::QualifiedName);
  23. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  24. Optional<NumberPercentage> m_offset;
  25. Optional<Gfx::Color> m_color;
  26. };
  27. }