2023-04-20 18:51:00 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-05-08 07:51:03 +02:00
|
|
|
#include <LibGfx/Color.h>
|
2023-04-20 18:51:00 +01:00
|
|
|
#include <LibWeb/SVG/AttributeParser.h>
|
|
|
|
|
#include <LibWeb/SVG/SVGAnimatedNumber.h>
|
|
|
|
|
#include <LibWeb/SVG/SVGElement.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
|
2024-10-28 19:38:53 +01:00
|
|
|
// https://svgwg.org/svg2-draft/pservers.html#GradientStops
|
2023-04-20 18:51:00 +01:00
|
|
|
class SVGStopElement final : public SVGElement {
|
|
|
|
|
WEB_PLATFORM_OBJECT(SVGStopElement, SVGElement);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(SVGStopElement);
|
2023-04-20 18:51:00 +01:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual ~SVGStopElement() override = default;
|
|
|
|
|
|
2024-11-14 08:14:16 -05:00
|
|
|
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
2023-04-20 18:51:00 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<SVGAnimatedNumber> offset() const;
|
2023-04-20 18:51:00 +01:00
|
|
|
|
|
|
|
|
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
|
|
|
|
|
|
|
|
|
NumberPercentage stop_offset() const { return m_offset.value_or(NumberPercentage::create_number(0)); }
|
|
|
|
|
Gfx::Color stop_color() const;
|
2023-05-19 20:35:39 +01:00
|
|
|
float stop_opacity() const;
|
2023-04-20 18:51:00 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
SVGStopElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-04-20 18:51:00 +01:00
|
|
|
|
|
|
|
|
Optional<NumberPercentage> m_offset;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|