Skip to content

Commit

Permalink
LibWeb: Return a dummy value from various SVG getters
Browse files Browse the repository at this point in the history
Instead of crashing with a TODO() on half of the test cases generated by
Domato, let's just return a zeroed-out SVGAnimatedLength or
SVGAnimatedNumber from getters that return them.

We'll eventually have to implement these correctly, but crashing is not
productive since it blocks us from finding other issues.
  • Loading branch information
awesomekling committed Mar 11, 2024
1 parent 35f359c commit 9aefc5c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
12 changes: 8 additions & 4 deletions Userland/Libraries/LibWeb/SVG/SVGLinearGradientElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,26 @@ Optional<Gfx::PaintStyle const&> SVGLinearGradientElement::to_gfx_paint_style(SV

JS::NonnullGCPtr<SVGAnimatedLength> SVGLinearGradientElement::x1() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGLinearGradientElement::y1() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGLinearGradientElement::x2() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGLinearGradientElement::y2() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

}
18 changes: 12 additions & 6 deletions Userland/Libraries/LibWeb/SVG/SVGRadialGradientElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,32 +216,38 @@ Optional<Gfx::PaintStyle const&> SVGRadialGradientElement::to_gfx_paint_style(SV

JS::NonnullGCPtr<SVGAnimatedLength> SVGRadialGradientElement::cx() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGRadialGradientElement::cy() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGRadialGradientElement::fx() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGRadialGradientElement::fy() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGRadialGradientElement::fr() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGRadialGradientElement::r() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

}
3 changes: 2 additions & 1 deletion Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ float SVGStopElement::stop_opacity() const

JS::NonnullGCPtr<SVGAnimatedNumber> SVGStopElement::offset() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedNumber::create(realm(), 0, 0);
}

void SVGStopElement::initialize(JS::Realm& realm)
Expand Down
6 changes: 4 additions & 2 deletions Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ JS::NonnullGCPtr<SVGAnimatedLength> SVGUseElement::y() const

JS::NonnullGCPtr<SVGAnimatedLength> SVGUseElement::width() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

JS::NonnullGCPtr<SVGAnimatedLength> SVGUseElement::height() const
{
TODO();
// FIXME: Implement this properly.
return SVGAnimatedLength::create(realm(), SVGLength::create(realm(), 0, 0), SVGLength::create(realm(), 0, 0));
}

// https://svgwg.org/svg2-draft/struct.html#TermInstanceRoot
Expand Down

0 comments on commit 9aefc5c

Please sign in to comment.