1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37:45 +00:00

LibWeb: Implement SVGStopElement (<stop>)

This is used to specify the color/position of color stops for SVG
gradients.
This commit is contained in:
MacDue 2023-04-20 18:51:00 +01:00 committed by Andreas Kling
parent 297d8eebcd
commit b19d2634f6
7 changed files with 116 additions and 1 deletions

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/SVG/AttributeParser.h>
#include <LibWeb/SVG/SVGAnimatedNumber.h>
#include <LibWeb/SVG/SVGElement.h>
namespace Web::SVG {
class SVGStopElement final : public SVGElement {
WEB_PLATFORM_OBJECT(SVGStopElement, SVGElement);
public:
virtual ~SVGStopElement() override = default;
virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
JS::NonnullGCPtr<SVGAnimatedNumber> offset() const;
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;
private:
SVGStopElement(DOM::Document&, DOM::QualifiedName);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
Optional<NumberPercentage> m_offset;
Optional<Gfx::Color> m_color;
};
}