1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:17:35 +00:00

AK+Everywhere: Remove the null state of DeprecatedString

This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
This commit is contained in:
Ali Mohammad Pur 2023-10-10 15:00:58 +03:30 committed by Ali Mohammad Pur
parent daf6d8173c
commit aeee98b3a1
189 changed files with 597 additions and 652 deletions

View file

@ -22,18 +22,18 @@ void SVGCircleElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGCircleElementPrototype>(realm, "SVGCircleElement"));
}
void SVGCircleElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGCircleElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::cx) {
m_center_x = AttributeParser::parse_coordinate(value);
m_center_x = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::cy) {
m_center_y = AttributeParser::parse_coordinate(value);
m_center_y = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::r) {
m_radius = AttributeParser::parse_positive_length(value);
m_radius = AttributeParser::parse_positive_length(value.value_or(""));
m_path.clear();
}
}

View file

@ -17,7 +17,7 @@ class SVGCircleElement final : public SVGGeometryElement {
public:
virtual ~SVGCircleElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Gfx::Path& get_path() override;

View file

@ -34,7 +34,7 @@ void SVGElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_dataset);
}
void SVGElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
Base::attribute_changed(name, value);

View file

@ -17,7 +17,7 @@ class SVGElement : public DOM::Element {
public:
virtual bool requires_svg_container() const override { return true; }
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual void children_changed() override;
virtual void inserted() override;

View file

@ -22,21 +22,21 @@ void SVGEllipseElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGEllipseElementPrototype>(realm, "SVGEllipseElement"));
}
void SVGEllipseElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGEllipseElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::cx) {
m_center_x = AttributeParser::parse_coordinate(value);
m_center_x = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::cy) {
m_center_y = AttributeParser::parse_coordinate(value);
m_center_y = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::rx) {
m_radius_x = AttributeParser::parse_positive_length(value);
m_radius_x = AttributeParser::parse_positive_length(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::ry) {
m_radius_y = AttributeParser::parse_positive_length(value);
m_radius_y = AttributeParser::parse_positive_length(value.value_or(""));
m_path.clear();
}
}

View file

@ -17,7 +17,7 @@ class SVGEllipseElement final : public SVGGeometryElement {
public:
virtual ~SVGEllipseElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Gfx::Path& get_path() override;

View file

@ -17,15 +17,15 @@ SVGGradientElement::SVGGradientElement(DOM::Document& document, DOM::QualifiedNa
{
}
void SVGGradientElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGGradientElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGElement::attribute_changed(name, value);
if (name == AttributeNames::gradientUnits) {
m_gradient_units = AttributeParser::parse_units(value);
m_gradient_units = AttributeParser::parse_units(value.value_or(""));
} else if (name == AttributeNames::spreadMethod) {
m_spread_method = AttributeParser::parse_spread_method(value);
m_spread_method = AttributeParser::parse_spread_method(value.value_or(""));
} else if (name == AttributeNames::gradientTransform) {
if (auto transform_list = AttributeParser::parse_transform(value); transform_list.has_value()) {
if (auto transform_list = AttributeParser::parse_transform(value.value_or("")); transform_list.has_value()) {
m_gradient_transform = transform_from_transform_list(*transform_list);
} else {
m_gradient_transform = {};

View file

@ -40,7 +40,7 @@ class SVGGradientElement : public SVGElement {
public:
virtual ~SVGGradientElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const = 0;

View file

@ -32,11 +32,11 @@ void SVGGraphicsElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGGraphicsElementPrototype>(realm, "SVGGraphicsElement"));
}
void SVGGraphicsElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGGraphicsElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGElement::attribute_changed(name, value);
if (name == "transform"sv) {
auto transform_list = AttributeParser::parse_transform(value);
auto transform_list = AttributeParser::parse_transform(value.value_or(""));
if (transform_list.has_value())
m_transform = transform_from_transform_list(*transform_list);
}

View file

@ -25,7 +25,7 @@ class SVGGraphicsElement : public SVGElement {
public:
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
Optional<Gfx::Color> fill_color() const;
Optional<FillRule> fill_rule() const;

View file

@ -22,21 +22,21 @@ void SVGLineElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLineElementPrototype>(realm, "SVGLineElement"));
}
void SVGLineElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGLineElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::x1) {
m_x1 = AttributeParser::parse_coordinate(value);
m_x1 = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::y1) {
m_y1 = AttributeParser::parse_coordinate(value);
m_y1 = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::x2) {
m_x2 = AttributeParser::parse_coordinate(value);
m_x2 = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::y2) {
m_y2 = AttributeParser::parse_coordinate(value);
m_y2 = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
}
}

View file

@ -17,7 +17,7 @@ class SVGLineElement final : public SVGGeometryElement {
public:
virtual ~SVGLineElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Gfx::Path& get_path() override;

View file

@ -24,22 +24,22 @@ void SVGLinearGradientElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGLinearGradientElementPrototype>(realm, "SVGLinearGradientElement"));
}
void SVGLinearGradientElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGLinearGradientElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGradientElement::attribute_changed(name, value);
// FIXME: Should allow for `<number-percentage> | <length>` for x1, x2, y1, y2
if (name == SVG::AttributeNames::x1) {
m_x1 = AttributeParser::parse_number_percentage(value);
m_x1 = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::y1) {
m_y1 = AttributeParser::parse_number_percentage(value);
m_y1 = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::x2) {
m_x2 = AttributeParser::parse_number_percentage(value);
m_x2 = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::y2) {
m_y2 = AttributeParser::parse_number_percentage(value);
m_y2 = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
}
}

View file

@ -18,7 +18,7 @@ class SVGLinearGradientElement : public SVGGradientElement {
public:
virtual ~SVGLinearGradientElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const override;

View file

@ -31,13 +31,13 @@ JS::GCPtr<Layout::Node> SVGMaskElement::create_layout_node(NonnullRefPtr<CSS::St
return heap().allocate_without_realm<Layout::SVGGraphicsBox>(document(), *this, move(style));
}
void SVGMaskElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGMaskElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGraphicsElement::attribute_changed(name, value);
if (name == AttributeNames::maskUnits) {
m_mask_units = AttributeParser::parse_units(value);
m_mask_units = AttributeParser::parse_units(value.value_or(""));
} else if (name == AttributeNames::maskContentUnits) {
m_mask_content_units = AttributeParser::parse_units(value);
m_mask_content_units = AttributeParser::parse_units(value.value_or(""));
}
}

View file

@ -17,7 +17,7 @@ class SVGMaskElement final : public SVGGraphicsElement {
public:
virtual ~SVGMaskElement() override;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;

View file

@ -95,12 +95,12 @@ void SVGPathElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPathElementPrototype>(realm, "SVGPathElement"));
}
void SVGPathElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGPathElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGeometryElement::attribute_changed(name, value);
if (name == "d") {
m_instructions = AttributeParser::parse_path_data(value);
m_instructions = AttributeParser::parse_path_data(value.value_or(""));
m_path.clear();
}
}

View file

@ -19,7 +19,7 @@ class SVGPathElement final : public SVGGeometryElement {
public:
virtual ~SVGPathElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Gfx::Path& get_path() override;

View file

@ -22,12 +22,12 @@ void SVGPolygonElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolygonElementPrototype>(realm, "SVGPolygonElement"));
}
void SVGPolygonElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGPolygonElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::points) {
m_points = AttributeParser::parse_points(value);
m_points = AttributeParser::parse_points(value.value_or(""));
m_path.clear();
}
}

View file

@ -16,7 +16,7 @@ class SVGPolygonElement final : public SVGGeometryElement {
public:
virtual ~SVGPolygonElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Gfx::Path& get_path() override;

View file

@ -22,12 +22,12 @@ void SVGPolylineElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGPolylineElementPrototype>(realm, "SVGPolylineElement"));
}
void SVGPolylineElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGPolylineElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::points) {
m_points = AttributeParser::parse_points(value);
m_points = AttributeParser::parse_points(value.value_or(""));
m_path.clear();
}
}

View file

@ -16,7 +16,7 @@ class SVGPolylineElement final : public SVGGeometryElement {
public:
virtual ~SVGPolylineElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Gfx::Path& get_path() override;

View file

@ -21,29 +21,29 @@ void SVGRadialGradientElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRadialGradientElementPrototype>(realm, "SVGRadialGradientElement"));
}
void SVGRadialGradientElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGRadialGradientElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGradientElement::attribute_changed(name, value);
// FIXME: These are <length> or <coordinate> in the spec, but all examples seem to allow percentages
// and unitless values.
if (name == SVG::AttributeNames::cx) {
m_cx = AttributeParser::parse_number_percentage(value);
m_cx = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::cy) {
m_cy = AttributeParser::parse_number_percentage(value);
m_cy = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::fx) {
m_fx = AttributeParser::parse_number_percentage(value);
m_fx = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::fy) {
m_fy = AttributeParser::parse_number_percentage(value);
m_fy = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::fr) {
m_fr = AttributeParser::parse_number_percentage(value);
m_fr = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
} else if (name == SVG::AttributeNames::r) {
m_r = AttributeParser::parse_number_percentage(value);
m_r = AttributeParser::parse_number_percentage(value.value_or(""));
m_paint_style = nullptr;
}
}

View file

@ -18,7 +18,7 @@ class SVGRadialGradientElement : public SVGGradientElement {
public:
virtual ~SVGRadialGradientElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Optional<Gfx::PaintStyle const&> to_gfx_paint_style(SVGPaintContext const&) const override;

View file

@ -24,27 +24,27 @@ void SVGRectElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGRectElementPrototype>(realm, "SVGRectElement"));
}
void SVGRectElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGRectElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGeometryElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::x) {
m_x = AttributeParser::parse_coordinate(value);
m_x = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::y) {
m_y = AttributeParser::parse_coordinate(value);
m_y = AttributeParser::parse_coordinate(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::width) {
m_width = AttributeParser::parse_positive_length(value);
m_width = AttributeParser::parse_positive_length(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::height) {
m_height = AttributeParser::parse_positive_length(value);
m_height = AttributeParser::parse_positive_length(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::rx) {
m_radius_x = AttributeParser::parse_length(value);
m_radius_x = AttributeParser::parse_length(value.value_or(""));
m_path.clear();
} else if (name == SVG::AttributeNames::ry) {
m_radius_y = AttributeParser::parse_length(value);
m_radius_y = AttributeParser::parse_length(value.value_or(""));
m_path.clear();
}
}

View file

@ -17,7 +17,7 @@ class SVGRectElement final : public SVGGeometryElement {
public:
virtual ~SVGRectElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual Gfx::Path& get_path() override;

View file

@ -38,7 +38,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
{
Base::apply_presentational_hints(style);
auto width_attribute = deprecated_attribute(SVG::AttributeNames::width);
auto width_attribute = attribute(SVG::AttributeNames::width);
auto parsing_context = CSS::Parser::ParsingContext { document(), CSS::Parser::ParsingContext::Mode::SVGPresentationAttribute };
if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) {
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
@ -50,7 +50,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
}
// Height defaults to 100%
auto height_attribute = deprecated_attribute(SVG::AttributeNames::height);
auto height_attribute = attribute(SVG::AttributeNames::height);
if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) {
style.set_property(CSS::PropertyID::Height, height_value.release_nonnull());
} else if (height_attribute == "") {
@ -61,14 +61,14 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
}
}
void SVGSVGElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGSVGElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGraphicsElement::attribute_changed(name, value);
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox))
m_view_box = try_parse_view_box(value);
m_view_box = try_parse_view_box(value.value_or(""));
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::preserveAspectRatio))
m_preserve_aspect_ratio = AttributeParser::parse_preserve_aspect_ratio(value);
m_preserve_aspect_ratio = AttributeParser::parse_preserve_aspect_ratio(value.value_or(""));
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::width) || name.equals_ignoring_ascii_case(SVG::AttributeNames::height))
update_fallback_view_box_for_svg_as_image();
}

View file

@ -36,7 +36,7 @@ private:
virtual bool is_svg_svg_element() const override { return true; }
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
void update_fallback_view_box_for_svg_as_image();

View file

@ -19,11 +19,11 @@ SVGStopElement::SVGStopElement(DOM::Document& document, DOM::QualifiedName quali
{
}
void SVGStopElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGStopElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::offset) {
m_offset = AttributeParser::parse_number_percentage(value);
m_offset = AttributeParser::parse_number_percentage(value.value_or(""));
}
}

View file

@ -19,7 +19,7 @@ class SVGStopElement final : public SVGElement {
public:
virtual ~SVGStopElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
JS::NonnullGCPtr<SVGAnimatedNumber> offset() const;

View file

@ -39,10 +39,10 @@ void SVGSymbolElement::apply_presentational_hints(CSS::StyleProperties& style) c
}
}
void SVGSymbolElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGSymbolElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
if (name.equals_ignoring_ascii_case(SVG::AttributeNames::viewBox))
m_view_box = try_parse_view_box(value);
m_view_box = try_parse_view_box(value.value_or(""));
}
bool SVGSymbolElement::is_direct_child_of_use_shadow_tree() const

View file

@ -29,7 +29,7 @@ private:
bool is_direct_child_of_use_shadow_tree() const;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
Optional<ViewBox> m_view_box;
};

View file

@ -28,18 +28,18 @@ void SVGTextPositioningElement::initialize(JS::Realm& realm)
set_prototype(&Bindings::ensure_web_prototype<Bindings::SVGTextPositioningElementPrototype>(realm, "SVGTextPositioningElement"));
}
void SVGTextPositioningElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGTextPositioningElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
SVGGraphicsElement::attribute_changed(name, value);
if (name == SVG::AttributeNames::x) {
m_x = AttributeParser::parse_coordinate(value).value_or(m_x);
m_x = AttributeParser::parse_coordinate(value.value_or("")).value_or(m_x);
} else if (name == SVG::AttributeNames::y) {
m_y = AttributeParser::parse_coordinate(value).value_or(m_y);
m_y = AttributeParser::parse_coordinate(value.value_or("")).value_or(m_y);
} else if (name == SVG::AttributeNames::dx) {
m_dx = AttributeParser::parse_coordinate(value).value_or(m_dx);
m_dx = AttributeParser::parse_coordinate(value.value_or("")).value_or(m_dx);
} else if (name == SVG::AttributeNames::dy) {
m_dy = AttributeParser::parse_coordinate(value).value_or(m_dy);
m_dy = AttributeParser::parse_coordinate(value.value_or("")).value_or(m_dy);
}
}

View file

@ -16,7 +16,7 @@ class SVGTextPositioningElement : public SVGTextContentElement {
WEB_PLATFORM_OBJECT(SVGTextPositioningElement, SVGTextContentElement);
public:
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
Gfx::FloatPoint get_offset() const;

View file

@ -45,18 +45,18 @@ void SVGUseElement::visit_edges(Cell::Visitor& visitor)
visitor.visit(m_document_observer);
}
void SVGUseElement::attribute_changed(FlyString const& name, DeprecatedString const& value)
void SVGUseElement::attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value)
{
Base::attribute_changed(name, value);
// https://svgwg.org/svg2-draft/struct.html#UseLayout
if (name == SVG::AttributeNames::x) {
m_x = AttributeParser::parse_coordinate(value);
m_x = AttributeParser::parse_coordinate(value.value_or(""));
} else if (name == SVG::AttributeNames::y) {
m_y = AttributeParser::parse_coordinate(value);
m_y = AttributeParser::parse_coordinate(value.value_or(""));
} else if (name == SVG::AttributeNames::href) {
// FIXME: Support the xlink:href attribute as a fallback
m_referenced_id = parse_id_from_href(value);
m_referenced_id = parse_id_from_href(value.value_or(""));
clone_element_tree_as_our_shadow_tree(referenced_element());
}

View file

@ -20,7 +20,7 @@ class SVGUseElement final : public SVGGraphicsElement {
public:
virtual ~SVGUseElement() override = default;
virtual void attribute_changed(FlyString const& name, DeprecatedString const& value) override;
virtual void attribute_changed(FlyString const& name, Optional<DeprecatedString> const& value) override;
virtual void inserted() override;