Bug 199843

Summary: [SVG2]: Add auto behavior for rx and ry to the SVG <ellipse> and <rect> elements
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: SVGAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, dbates, dino, esprehn+autocc, ews-watchlist, fmalita, glenn, gyuyoung.kim, joepeck, koivisto, kondapallykalyan, macpherson, menard, pdr, rniwa, schenney, sergio, simon.fraser, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 201663    
Bug Blocks: 191292, 200143    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Said Abou-Hallawa 2019-07-16 16:37:52 PDT
Specs: https://www.w3.org/TR/SVG/geometry.html#RX

Test case:

<svg xmlns="http://www.w3.org/2000/svg">
    <ellipse style="rx: auto;" ry="30" cx="50" cy="50" fill="none" stroke="blue" stroke-width="5"/>
</svg>
Comment 3 Said Abou-Hallawa 2019-09-18 09:57:59 PDT
Created attachment 379046 [details]
Patch
Comment 4 Nikolas Zimmermann 2019-09-18 10:05:48 PDT
Comment on attachment 379046 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=379046&action=review

Nice tests, thanks Said.

> LayoutTests/ChangeLog:3
> +        [SVG2]: Add auto behavior for rx and ry to the SVG <ellipse> and<rect> elements

and<rect> -> and <rect>

> LayoutTests/ChangeLog:8
> +        Skip the tests with dynmaic chnages till webkit.org/b/201918 is fixed.

typo: dynamic changes.
Maybe add one sentence regarding the new tests?
Comment 5 Said Abou-Hallawa 2019-09-18 11:13:45 PDT
Created attachment 379050 [details]
Patch
Comment 6 Said Abou-Hallawa 2019-09-18 11:19:11 PDT
Comment on attachment 379046 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=379046&action=review

>> LayoutTests/ChangeLog:3
>> +        [SVG2]: Add auto behavior for rx and ry to the SVG <ellipse> and<rect> elements
> 
> and<rect> -> and <rect>

Fixed. I just realized the space key in my keyboard is malfunctioning. It got stuck many times while typing this comment.

>> LayoutTests/ChangeLog:8
>> +        Skip the tests with dynmaic chnages till webkit.org/b/201918 is fixed.
> 
> typo: dynamic changes.
> Maybe add one sentence regarding the new tests?

The typo is fixed and comments were added regarding the new tests.
Comment 7 Nikolas Zimmermann 2019-09-18 11:23:41 PDT
Comment on attachment 379050 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=379050&action=review

Sorry, just found another typo :/ For me the code changes look just fine.

> Source/WebCore/ChangeLog:8
> +        The sepcs is: https://www.w3.org/TR/SVG2/geometry.html#RxProperty.

sepcs, spec :-)

> Source/WebCore/ChangeLog:11
> +        parse LengthOrAuto for these  properties. Handle the case if one of them

s/these  /these /
Comment 8 Simon Fraser (smfr) 2019-09-19 02:54:49 PDT
Comment on attachment 379050 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=379050&action=review

> Source/WebCore/rendering/svg/RenderSVGEllipse.cpp:92
> +    Length rx = style().svgStyle().rx().isAuto() ? style().svgStyle().ry() : style().svgStyle().rx();

Maybe avoid reading style().svgStyle().rx() twice. 

Length rx = style().svgStyle().rx();
if (rx.isAuto()
  rx = style().svgStyle().ry();
Comment 9 Said Abou-Hallawa 2019-09-19 10:48:24 PDT
Created attachment 379147 [details]
Patch
Comment 10 WebKit Commit Bot 2019-09-19 13:51:33 PDT
The commit-queue encountered the following flaky tests while processing attachment 379147 [details]:

imported/w3c/web-platform-tests/websockets/bufferedAmount-unchanged-by-sync-xhr.any.worker.html bug 202003 (author: youennf@gmail.com)
The commit-queue is continuing to process your patch.
Comment 11 WebKit Commit Bot 2019-09-19 13:52:36 PDT
Comment on attachment 379147 [details]
Patch

Clearing flags on attachment: 379147

Committed r250103: <https://trac.webkit.org/changeset/250103>
Comment 12 WebKit Commit Bot 2019-09-19 13:52:39 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Radar WebKit Bug Importer 2019-09-19 13:53:16 PDT
<rdar://problem/55532838>
Comment 14 Darin Adler 2019-09-19 17:55:57 PDT
Comment on attachment 379147 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=379147&action=review

> Source/WebCore/rendering/svg/RenderSVGEllipse.cpp:98
> +    Length rx = style().svgStyle().rx();
> +    if (rx.isAuto())
> +        rx = style().svgStyle().ry();
> +    
> +    Length ry = style().svgStyle().ry();
> +    if (ry.isAuto())
> +        ry = style().svgStyle().rx();

How about this alternative version?

    Length rx = style().svgStyle().rx();
    Length ry = style().svgStyle().ry();
    if (rx.isAuto())
        rx = ry;
    else if (ry.isAuto())
        ry = rx;
Comment 15 Said Abou-Hallawa 2019-09-19 18:25:42 PDT
Comment on attachment 379147 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=379147&action=review

>> Source/WebCore/rendering/svg/RenderSVGEllipse.cpp:98
>> +        ry = style().svgStyle().rx();
> 
> How about this alternative version?
> 
>     Length rx = style().svgStyle().rx();
>     Length ry = style().svgStyle().ry();
>     if (rx.isAuto())
>         rx = ry;
>     else if (ry.isAuto())
>         ry = rx;

I agree.

-- In the worst case scenario, which happens when rx and ry are both 'auto', my solution will calculate rx/ry four times. It will also call the Length::operator==() four times.
-- Your solution will calculate rx/ry two times and will call Length::operator==() three times.
-- How about this?

    Length rx = style().svgStyle().rx();
    Length ry = style().svgStyle().ry();
    m_radii = FloatSize(
        lengthContext.valueForLength(rx.isAuto() ? ry : rx, SVGLengthMode::Width),
        lengthContext.valueForLength(ry.isAuto() ? rx : ry, SVGLengthMode::Height));

This will calculate rx/ry two times and will call Length::operator==() two times.
Comment 16 Said Abou-Hallawa 2019-09-20 08:49:43 PDT
Reopening to attach new patch.
Comment 17 Said Abou-Hallawa 2019-09-20 08:49:44 PDT
Created attachment 379243 [details]
Patch
Comment 18 WebKit Commit Bot 2019-09-20 13:30:40 PDT
Comment on attachment 379243 [details]
Patch

Clearing flags on attachment: 379243

Committed r250147: <https://trac.webkit.org/changeset/250147>
Comment 19 WebKit Commit Bot 2019-09-20 13:30:42 PDT
All reviewed patches have been landed.  Closing bug.