SVGStopElement.h 1.0 KB

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