Bug 259772

Summary: SVG rect with rx or ry set to zero is drawn incorrectly
Product: WebKit Reporter: kari.pihkala
Component: SVGAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: sabouhallawa, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
rect-rxry.svg none

Description kari.pihkala 2023-08-03 03:17:14 PDT
Created attachment 467192 [details]
rect-rxry.svg

Safari renders SVG <rect> elements with rx set to a value and ry set to a zero value with rounded corners. They should be drawn without rounded corners. The same happens if ry is set to a value and rx is set to a zero value.

The attached test case rect-rxry.svg ( fiddle: https://jsfiddle.net/d82x3nvs/ ) should have two rectangles drawn without rounded corners. Safari draws them with rounded corners.

Tested on Safari 16.5.2 (18615.2.9.11.10) and Safari Tech Preview Release 174 (Safari 17.0, WebKit 18616.1.22.1).

Firefox 115 and Chrome 115 render the test case correctly without rounded corners.

Safari 5.1.7 (7534.57.7) used to render the rectangles correctly without rounded corners. Rendering got broken some time after it and at least Safari 10.1.2 (12603.3.8) is drawing them incorrectly.
Comment 1 Radar WebKit Bug Importer 2023-08-04 07:33:17 PDT
<rdar://problem/113396109>
Comment 2 Said Abou-Hallawa 2023-08-04 09:33:15 PDT
One easy fix is to replace the following condition in LegacyRenderSVGRect::updateShapeFromElement() and RenderSVGRect::updateShapeFromElement()


if (rectElement().rx().value(lengthContext) > 0 || rectElement().ry().value(lengthContext) > 0 || hasNonScalingStroke()) {
    // Fall back to LegacyRenderSVGShape
    LegacyRenderSVGShape::updateShapeFromElement();
    return;
}

by 


if ((rectElement().rx().value(lengthContext) > 0 && rectElement().ry().value(lengthContext) > 0) || hasNonScalingStroke()) {
    // Fall back to LegacyRenderSVGShape
    LegacyRenderSVGShape::updateShapeFromElement();
    return;
}
Comment 3 Said Abou-Hallawa 2023-08-04 17:52:08 PDT
Pull request: https://github.com/WebKit/WebKit/pull/16414
Comment 4 EWS 2023-08-07 10:55:45 PDT
Committed 266641@main (3dc74d79ceb7): <https://commits.webkit.org/266641@main>

Reviewed commits have been landed. Closing PR #16414 and removing active labels.