2023-04-22 18:51:00 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/SVG/AttributeParser.h>
|
|
|
|
#include <LibWeb/SVG/SVGAnimatedLength.h>
|
|
|
|
#include <LibWeb/SVG/SVGGradientElement.h>
|
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
|
|
|
class SVGLinearGradientElement : public SVGGradientElement {
|
|
|
|
WEB_PLATFORM_OBJECT(SVGLinearGradientElement, SVGGradientElement);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(SVGLinearGradientElement);
|
2023-04-22 18:51:00 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SVGLinearGradientElement() 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-22 18:51:00 +01:00
|
|
|
|
2024-06-13 15:22:46 +03:00
|
|
|
virtual Optional<Painting::PaintStyle> to_gfx_paint_style(SVGPaintContext const&) const override;
|
2023-04-22 18:51:00 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<SVGAnimatedLength> x1() const;
|
|
|
|
GC::Ref<SVGAnimatedLength> y1() const;
|
|
|
|
GC::Ref<SVGAnimatedLength> x2() const;
|
|
|
|
GC::Ref<SVGAnimatedLength> y2() const;
|
2023-04-22 18:51:00 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
SVGLinearGradientElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-04-22 18:51:00 +01:00
|
|
|
|
|
|
|
private:
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<SVGLinearGradientElement const> linked_linear_gradient(HashTable<SVGGradientElement const*>& seen_gradients) const
|
2023-04-22 18:51:00 +01:00
|
|
|
{
|
2024-03-10 12:18:09 +01:00
|
|
|
if (auto gradient = linked_gradient(seen_gradients); gradient && is<SVGLinearGradientElement>(*gradient))
|
2025-01-21 09:12:05 -05:00
|
|
|
return &as<SVGLinearGradientElement>(*gradient);
|
2023-04-22 18:51:00 +01:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
NumberPercentage start_x() const;
|
|
|
|
NumberPercentage start_y() const;
|
|
|
|
NumberPercentage end_x() const;
|
|
|
|
NumberPercentage end_y() const;
|
|
|
|
|
2024-03-10 12:18:09 +01:00
|
|
|
NumberPercentage start_x_impl(HashTable<SVGGradientElement const*>& seen_gradients) const;
|
|
|
|
NumberPercentage start_y_impl(HashTable<SVGGradientElement const*>& seen_gradients) const;
|
|
|
|
NumberPercentage end_x_impl(HashTable<SVGGradientElement const*>& seen_gradients) const;
|
|
|
|
NumberPercentage end_y_impl(HashTable<SVGGradientElement const*>& seen_gradients) const;
|
|
|
|
|
2023-04-22 18:51:00 +01:00
|
|
|
Optional<NumberPercentage> m_x1;
|
|
|
|
Optional<NumberPercentage> m_y1;
|
|
|
|
Optional<NumberPercentage> m_x2;
|
|
|
|
Optional<NumberPercentage> m_y2;
|
|
|
|
|
2024-06-13 15:22:46 +03:00
|
|
|
mutable RefPtr<Painting::SVGLinearGradientPaintStyle> m_paint_style;
|
2023-04-22 18:51:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|