|
@@ -8,8 +8,10 @@
|
|
|
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/CSS/Parser/Parser.h>
|
|
#include <LibWeb/CSS/Parser/Parser.h>
|
|
|
|
+#include <LibWeb/DOM/Document.h>
|
|
#include <LibWeb/Layout/Node.h>
|
|
#include <LibWeb/Layout/Node.h>
|
|
#include <LibWeb/SVG/AttributeParser.h>
|
|
#include <LibWeb/SVG/AttributeParser.h>
|
|
|
|
+#include <LibWeb/SVG/SVGGradientElement.h>
|
|
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
|
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
|
#include <LibWeb/SVG/SVGSVGElement.h>
|
|
#include <LibWeb/SVG/SVGSVGElement.h>
|
|
|
|
|
|
@@ -40,6 +42,23 @@ void SVGGraphicsElement::parse_attribute(DeprecatedFlyString const& name, Deprec
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Optional<Gfx::PaintStyle const&> SVGGraphicsElement::fill_paint_style(SVGPaintContext const& paint_context) const
|
|
|
|
+{
|
|
|
|
+ // FIXME: This entire function is an ad-hoc hack:
|
|
|
|
+ if (!layout_node())
|
|
|
|
+ return {};
|
|
|
|
+ auto& fill = layout_node()->computed_values().fill();
|
|
|
|
+ if (!fill.has_value() || !fill->is_url())
|
|
|
|
+ return {};
|
|
|
|
+ auto& url = fill->as_url();
|
|
|
|
+ auto maybe_gradient = document().get_element_by_id(url.fragment());
|
|
|
|
+ if (is<SVG::SVGGradientElement>(*maybe_gradient)) {
|
|
|
|
+ auto& gradient = verify_cast<SVG::SVGGradientElement>(*maybe_gradient);
|
|
|
|
+ return gradient.to_gfx_paint_style(paint_context);
|
|
|
|
+ }
|
|
|
|
+ return {};
|
|
|
|
+}
|
|
|
|
+
|
|
Gfx::AffineTransform transform_from_transform_list(ReadonlySpan<Transform> transform_list)
|
|
Gfx::AffineTransform transform_from_transform_list(ReadonlySpan<Transform> transform_list)
|
|
{
|
|
{
|
|
Gfx::AffineTransform affine_transform;
|
|
Gfx::AffineTransform affine_transform;
|
|
@@ -111,8 +130,10 @@ Optional<Gfx::Color> SVGGraphicsElement::fill_color() const
|
|
return {};
|
|
return {};
|
|
// FIXME: In the working-draft spec, `fill` is intended to be a shorthand, with `fill-color`
|
|
// FIXME: In the working-draft spec, `fill` is intended to be a shorthand, with `fill-color`
|
|
// being what we actually want to use. But that's not final or widely supported yet.
|
|
// being what we actually want to use. But that's not final or widely supported yet.
|
|
- return layout_node()->computed_values().fill().map([&](Gfx::Color color) {
|
|
|
|
- return color.with_alpha(m_fill_opacity.value_or(1) * 255);
|
|
|
|
|
|
+ return layout_node()->computed_values().fill().map([&](auto& paint) -> Gfx::Color {
|
|
|
|
+ if (!paint.is_color())
|
|
|
|
+ return Color::Black;
|
|
|
|
+ return paint.as_color().with_alpha(m_fill_opacity.value_or(1) * 255);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -122,7 +143,11 @@ Optional<Gfx::Color> SVGGraphicsElement::stroke_color() const
|
|
return {};
|
|
return {};
|
|
// FIXME: In the working-draft spec, `stroke` is intended to be a shorthand, with `stroke-color`
|
|
// FIXME: In the working-draft spec, `stroke` is intended to be a shorthand, with `stroke-color`
|
|
// being what we actually want to use. But that's not final or widely supported yet.
|
|
// being what we actually want to use. But that's not final or widely supported yet.
|
|
- return layout_node()->computed_values().stroke();
|
|
|
|
|
|
+ return layout_node()->computed_values().stroke().map([](auto& paint) -> Gfx::Color {
|
|
|
|
+ if (!paint.is_color())
|
|
|
|
+ return Color::Black;
|
|
|
|
+ return paint.as_color();
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
Optional<float> SVGGraphicsElement::stroke_width() const
|
|
Optional<float> SVGGraphicsElement::stroke_width() const
|