Fix handling of 'auto' for 'rx' and 'ry' on <ellipse>

Per the spec[1][2], when 'auto' is specified for 'rx' or 'ry' the used
value of said property will be the used value of the other property
('rx' for 'ry' and vice versa.)

[1] https://svgwg.org/svg2-draft/geometry.html#RX
[2] https://svgwg.org/svg2-draft/geometry.html#RY

Bug: 861585
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Iec0a9179527a5b0e99cc6a0ec671e5b6d92f828b
Reviewed-on: https://chromium-review.googlesource.com/1128885
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#573457}
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 5221a67..80e7d91 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -2730,12 +2730,6 @@
 crbug.com/849859 external/wpt/web-animations/timing-model/animations/pausing-an-animation.html [ Failure ]
 
 # ====== New tests from wpt-importer added here ======
-crbug.com/626703 external/wpt/svg/shapes/ellipse-05.svg [ Failure ]
-crbug.com/626703 external/wpt/svg/shapes/ellipse-06.svg [ Failure ]
-crbug.com/626703 external/wpt/svg/shapes/ellipse-08.svg [ Failure ]
-crbug.com/626703 external/wpt/svg/shapes/ellipse-03.svg [ Failure ]
-crbug.com/626703 external/wpt/svg/shapes/ellipse-07.svg [ Failure ]
-crbug.com/626703 external/wpt/svg/shapes/ellipse-02.svg [ Failure ]
 crbug.com/626703 external/wpt/svg/rendering/order/z-index.svg [ Failure ]
 crbug.com/626703 external/wpt/websockets/Create-on-worker-shutdown.any.html [ Timeout ]
 crbug.com/626703 external/wpt/web-animations/timing-model/timelines/update-and-send-events.html [ Timeout ]
diff --git a/third_party/WebKit/LayoutTests/svg/custom/SVGEllipse-without-rx-or-ry-expected.svg b/third_party/WebKit/LayoutTests/svg/custom/SVGEllipse-without-rx-or-ry-expected.svg
index cfaad28..db7c1615 100644
--- a/third_party/WebKit/LayoutTests/svg/custom/SVGEllipse-without-rx-or-ry-expected.svg
+++ b/third_party/WebKit/LayoutTests/svg/custom/SVGEllipse-without-rx-or-ry-expected.svg
@@ -1,13 +1,13 @@
 <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
-    <ellipse rx="0"
+    <ellipse rx="50"
        ry="50"
        cx="100"
        cy="100"
        fill="green"/>
 
     <ellipse rx="80"
-       ry="0"
+       ry="80"
        cx="280"
        cy="100"
        fill="green"/>
-</svg>
\ No newline at end of file
+</svg>
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_ellipse.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_ellipse.cc
index ad066f7..10e0f346 100644
--- a/third_party/blink/renderer/core/layout/svg/layout_svg_ellipse.cc
+++ b/third_party/blink/renderer/core/layout/svg/layout_svg_ellipse.cc
@@ -94,6 +94,10 @@
   } else {
     radii_ = ToFloatSize(length_context.ResolveLengthPair(
         svg_style.Rx(), svg_style.Ry(), style));
+    if (svg_style.Rx().IsAuto())
+      radii_.SetWidth(radii_.Height());
+    else if (svg_style.Ry().IsAuto())
+      radii_.SetHeight(radii_.Width());
   }
 }
 
diff --git a/third_party/blink/renderer/core/svg/svg_ellipse_element.cc b/third_party/blink/renderer/core/svg/svg_ellipse_element.cc
index a49b4ca..2f2dfa88 100644
--- a/third_party/blink/renderer/core/svg/svg_ellipse_element.cc
+++ b/third_party/blink/renderer/core/svg/svg_ellipse_element.cc
@@ -69,6 +69,10 @@
 
   FloatSize radii(ToFloatSize(
       length_context.ResolveLengthPair(svg_style.Rx(), svg_style.Ry(), style)));
+  if (svg_style.Rx().IsAuto())
+    radii.SetWidth(radii.Height());
+  else if (svg_style.Ry().IsAuto())
+    radii.SetHeight(radii.Width());
   if (radii.Width() < 0 || radii.Height() < 0 ||
       (!radii.Width() && !radii.Height()))
     return path;