SVGStopElement.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. JS_DECLARE_ALLOCATOR(SVGStopElement);
  15. public:
  16. virtual ~SVGStopElement() override = default;
  17. virtual void attribute_changed(FlyString const& name, Optional<String> const& value) override;
  18. JS::NonnullGCPtr<SVGAnimatedNumber> offset() const;
  19. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  20. NumberPercentage stop_offset() const { return m_offset.value_or(NumberPercentage::create_number(0)); }
  21. Gfx::Color stop_color() const;
  22. float stop_opacity() const;
  23. private:
  24. SVGStopElement(DOM::Document&, DOM::QualifiedName);
  25. virtual void initialize(JS::Realm&) override;
  26. Optional<NumberPercentage> m_offset;
  27. Optional<Gfx::Color> m_color;
  28. };
  29. }