2020-07-19 23:01:53 -07:00
|
|
|
/*
|
2021-04-22 16:53:07 -07:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2020-07-19 23:01:53 -07:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-19 23:01:53 -07:00
|
|
|
*/
|
|
|
|
|
2022-12-28 22:40:40 +01:00
|
|
|
#include <AK/Optional.h>
|
2024-08-08 15:12:29 +02:00
|
|
|
#include <LibGfx/Path.h>
|
2024-04-27 12:09:58 +12:00
|
|
|
#include <LibWeb/Bindings/SVGPathElementPrototype.h>
|
2020-07-19 23:01:53 -07:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
|
|
|
#include <LibWeb/DOM/Event.h>
|
2022-02-11 12:37:22 +00:00
|
|
|
#include <LibWeb/Layout/SVGGeometryBox.h>
|
2020-07-23 09:44:42 -07:00
|
|
|
#include <LibWeb/SVG/SVGPathElement.h>
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
namespace Web::SVG {
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DEFINE_ALLOCATOR(SVGPathElement);
|
2023-11-19 19:47:52 +01:00
|
|
|
|
2022-02-18 21:00:52 +01:00
|
|
|
SVGPathElement::SVGPathElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
2021-02-07 11:20:15 +01:00
|
|
|
: SVGGeometryElement(document, move(qualified_name))
|
2020-07-19 23:01:53 -07:00
|
|
|
{
|
2023-01-10 06:28:20 -05:00
|
|
|
}
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
void SVGPathElement::initialize(JS::Realm& realm)
|
2023-01-10 06:28:20 -05:00
|
|
|
{
|
2024-03-16 13:13:08 +01:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGPathElement);
|
2025-04-20 16:22:57 +02:00
|
|
|
Base::initialize(realm);
|
2020-07-19 23:01:53 -07:00
|
|
|
}
|
|
|
|
|
2024-11-14 08:14:16 -05:00
|
|
|
void SVGPathElement::attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_)
|
2020-07-19 23:01:53 -07:00
|
|
|
{
|
2024-11-14 08:14:16 -05:00
|
|
|
Base::attribute_changed(name, old_value, value, namespace_);
|
2020-07-22 15:17:39 -07:00
|
|
|
|
2024-03-03 20:15:06 +00:00
|
|
|
if (name == "d")
|
2025-07-17 15:04:25 +01:00
|
|
|
m_path = AttributeParser::parse_path_data(value.value_or(String {}));
|
2022-11-29 14:06:41 +01:00
|
|
|
}
|
|
|
|
|
2024-08-09 14:00:10 +02:00
|
|
|
Gfx::Path SVGPathElement::get_path(CSSPixelSize)
|
2022-11-29 14:06:41 +01:00
|
|
|
{
|
2025-07-17 15:04:25 +01:00
|
|
|
return m_path.to_gfx_path();
|
2020-07-19 23:01:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|