Truly independent web browser
/*
* Copyright (c) 2022, Andreas Kling <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/SVG/AttributeParsing.h>
#include <LibWeb/SVG/SVGElement.h>
#include <LibWeb/SVG/SVGGraphicsElement.h>
namespace Web::SVG {
class SVGClipPathElement final : public SVGGraphicsElement {
WEB_WRAPPABLE(SVGClipPathElement, SVGGraphicsElement);
GC_DECLARE_ALLOCATOR(SVGClipPathElement);
public:
virtual ~SVGClipPathElement();
virtual Optional<ViewBox> active_view_box() const override
{
// Same trick as SVGMaskElement.
if (clip_path_units() == MaskContentUnits::ObjectBoundingBox)
return ViewBox { 0, 0, 1, 1 };
return {};
}
virtual void attribute_changed(Utf16FlyString const& name, Optional<Utf16String> const& old_value, Optional<Utf16String> const& value, Optional<Utf16FlyString> const& namespace_) override;
ClipPathUnits clip_path_units() const
{
return m_clip_path_units.value_or(ClipPathUnits::UserSpaceOnUse);
}
virtual CSS::ElementBoxKind box_kind() const override;
GC::Ref<SVGAnimatedEnumeration> clip_path_units_for_bindings();
private:
SVGClipPathElement(DOM::Document&, DOM::QualifiedName);
virtual bool is_svg_clip_path_element() const final { return true; }
Optional<ClipPathUnits> m_clip_path_units = {};
};
}
namespace Web::DOM {
template<>
inline bool Node::fast_is<SVG::SVGClipPathElement>() const { return is_svg_clip_path_element(); }
}