SVGStopElement.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 attribute_changed(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. float stop_opacity() const;
  22. private:
  23. SVGStopElement(DOM::Document&, DOM::QualifiedName);
  24. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  25. Optional<NumberPercentage> m_offset;
  26. Optional<Gfx::Color> m_color;
  27. };
  28. }