CSS: path string computed style uses absolute commands

The canonical computed style format for path strings uses absolute
commands only.

Discussed in https://github.com/w3c/svgwg/issues/321

Previously, Blink only normalized path string to absolute commands
when they were animated.

BUG=696395

Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I773ceb40f22fc5ce1e5f7ea0b4eca6cc612e763e
Reviewed-on: https://chromium-review.googlesource.com/1215150
Commit-Queue: Eric Willigers <ericwilligers@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#591996}
diff --git a/css/motion/offset-path-serialization.html b/css/motion/offset-path-serialization.html
new file mode 100644
index 0000000..1c00091
--- /dev/null
+++ b/css/motion/offset-path-serialization.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Motion Path Module Level 1: path serialization</title>
+<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
+<link rel="help" href="https://drafts.fxtf.org/motion-1/">
+<h:meta name="assert" content="computed offset-path is serialized using absolute commands"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="target"></div>
+<script>
+'use strict';
+
+test(function() {
+  var target = document.getElementById('target');
+
+  target.style.offsetPath = 'path("m 10 20 q 30 60 40 50 q 100 70 90 80")';
+  assert_equals(target.style.offsetPath, 'path("m 10 20 q 30 60 40 50 q 100 70 90 80")');
+  assert_equals(getComputedStyle(target).offsetPath, 'path("M 10 20 Q 40 80 50 70 Q 150 140 140 150")');
+
+  target.style.offsetPath = "path('M 0 0 L 100 100 m 0 100 l 100 0 Z l 160 20 Z')";
+  assert_equals(target.style.offsetPath, 'path("M 0 0 L 100 100 m 0 100 l 100 0 Z l 160 20 Z")');
+  assert_equals(getComputedStyle(target).offsetPath, 'path("M 0 0 L 100 100 M 100 200 L 200 200 Z L 260 220 Z")');
+
+  target.style.offsetPath = 'path("m 10 20   l 20 30   Z   l 50 60   Z   m 70 80   l 90 60   Z   t 70 120")';
+  assert_equals(target.style.offsetPath, 'path("m 10 20 l 20 30 Z l 50 60 Z m 70 80 l 90 60 Z t 70 120")');
+  assert_equals(getComputedStyle(target).offsetPath, 'path("M 10 20 L 30 50 Z L 60 80 Z M 80 100 L 170 160 Z T 150 220")');
+
+  target.style.offsetPath = 'path("m 10.0 170.0 h 90.00 v 30.00 m 0 0 s 1 2 3 4 z c 9 8 7 6 5 4")';
+  assert_equals(target.style.offsetPath, 'path("m 10 170 h 90 v 30 m 0 0 s 1 2 3 4 Z c 9 8 7 6 5 4")');
+  assert_equals(getComputedStyle(target).offsetPath, 'path("M 10 170 H 100 V 200 M 100 200 S 101 202 103 204 Z C 109 208 107 206 105 204")');
+
+  target.style.offsetPath = '  path(  "m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50"  )  ';
+  assert_equals(target.style.offsetPath, 'path("m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50")');
+  assert_equals(getComputedStyle(target).offsetPath, 'path("M 10 20 A 10 20 30 1 0 50 70 A 110 120 30 1 1 190 120")');
+});
+</script>
+</body>
+</html>
diff --git a/css/motion/parsing/offset-parsing-valid.html b/css/motion/parsing/offset-parsing-valid.html
index b93091b..3fe8a5b 100644
--- a/css/motion/parsing/offset-parsing-valid.html
+++ b/css/motion/parsing/offset-parsing-valid.html
@@ -30,11 +30,11 @@
 test_valid_value("offset", "path(\"M 0 0 H 1\") auto");
 test_valid_value("offset", "path('M 0 0 H 1') reverse 30deg 50px", "path(\"M 0 0 H 1\") 50px reverse 30deg");
 test_valid_value("offset", "path(\"M 0 0 H 1\")");
-test_valid_value("offset", "path('m 0 0 h 100') -7rad 8px / auto", "path(\"m 0 0 h 100\") 8px -7rad / auto");
-test_valid_value("offset", "path('m 0 0 h 100') -7rad 8px / left top", "path(\"m 0 0 h 100\") 8px -7rad / left top");
+test_valid_value("offset", "path('m 20 0 h 100') -7rad 8px / auto", "path(\"m 20 0 h 100\") 8px -7rad / auto");
+test_valid_value("offset", "path('m 0 30 v 100') -7rad 8px / left top", "path(\"m 0 30 v 100\") 8px -7rad / left top");
 test_valid_value("offset", "path('m 0 0 h 100') -7rad 8px", "path(\"m 0 0 h 100\") 8px -7rad");
-test_valid_value("offset", "path(\"m 0 0 h 100\") 100px 0deg");
-test_valid_value("offset", "path('m 1 2 v 3 Z')", "path(\"m 1 2 v 3 Z\")");
+test_valid_value("offset", "path(\"M 0 0 H 100\") 100px 0deg");
+test_valid_value("offset", "path(  'm 1 2   v 3.00 z')", "path(\"m 1 2 v 3 Z\")");
 test_valid_value("offset", "ray(farthest-corner 90deg) 1%", "ray(90deg farthest-corner) 1%");
 test_valid_value("offset", "ray(sides 0deg) 50% 90deg auto", "ray(0deg sides) 50% auto 90deg");
 test_valid_value("offset", "right bottom / left top");
diff --git a/css/motion/parsing/offset-path-parsing-valid.html b/css/motion/parsing/offset-path-parsing-valid.html
index bda8292..0ed360f 100644
--- a/css/motion/parsing/offset-path-parsing-valid.html
+++ b/css/motion/parsing/offset-path-parsing-valid.html
@@ -21,8 +21,13 @@
 test_valid_value("offset-path", "ray(-720deg sides)");
 test_valid_value("offset-path", "ray(calc(180deg - 45deg) farthest-side)", "ray(calc(135deg) farthest-side)");
 
-test_valid_value("offset-path", 'path("m 0 0 h -100")');
+test_valid_value("offset-path", 'path("m 20 0 h -100")');
 test_valid_value("offset-path", 'path("M 0 0 L 100 100 M 100 200 L 200 200 Z L 300 300 Z")');
+test_valid_value("offset-path", 'path("m 10 20 q 30 60 40 50 q 100 70 90 80")');
+test_valid_value("offset-path", 'path("M 0 0 L 100 100 m 0 100 l 100 0 Z l 160 20 Z")');
+test_valid_value("offset-path", 'path("m 10 20 l 20 30 Z l 50 60 Z m 70 80 l 90 60 Z t 70 120")');
+test_valid_value("offset-path", 'path("m 10 170 h 90 v 30 m 0 0 s 1 2 3 4 z c 9 8 7 6 5 4")', 'path("m 10 170 h 90 v 30 m 0 0 s 1 2 3 4 Z c 9 8 7 6 5 4")');
+test_valid_value("offset-path", 'path("m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50")');
 
 test_valid_value("offset-path", 'url("http://www.example.com/index.html#polyline1")');
 
diff --git a/svg/path/property/getComputedStyle.svg b/svg/path/property/getComputedStyle.svg
index 5830191..392c570 100644
--- a/svg/path/property/getComputedStyle.svg
+++ b/svg/path/property/getComputedStyle.svg
@@ -10,7 +10,7 @@
       d: path('M 10 3 H 30');
     }
     .g5 {
-      d: path('M 10 5 H 50');
+      d: path('m 10 5 h 40');
     }
     .p6 {
       d: inherit;
diff --git a/svg/path/property/serialization.svg b/svg/path/property/serialization.svg
new file mode 100644
index 0000000..297f8ed
--- /dev/null
+++ b/svg/path/property/serialization.svg
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:h="http://www.w3.org/1999/xhtml">
+  <metadata>
+    <h:link rel="help" href="https://svgwg.org/svg2-draft/paths.html#TheDProperty"/>
+    <h:meta name="assert" content="computed d is serialized using absolute commands"/>
+  </metadata>
+  <path id="target"></path>
+  <h:script src="/resources/testharness.js"/>
+  <h:script src="/resources/testharnessreport.js"/>
+  <script><![CDATA[
+  test(function() {
+    var target = document.getElementById('target');
+
+    target.style.d = 'path("m 10 20 q 30 60 40 50 q 100 70 90 80")';
+    assert_equals(target.style.d, 'path("m 10 20 q 30 60 40 50 q 100 70 90 80")');
+    assert_equals(getComputedStyle(target).d, 'path("M 10 20 Q 40 80 50 70 Q 150 140 140 150")');
+
+    target.style.d = "path('M 0 0 L 100 100 m 0 100 l 100 0 Z l 160 20 Z')";
+    assert_equals(target.style.d, 'path("M 0 0 L 100 100 m 0 100 l 100 0 Z l 160 20 Z")');
+    assert_equals(getComputedStyle(target).d, 'path("M 0 0 L 100 100 M 100 200 L 200 200 Z L 260 220 Z")');
+
+    target.style.d = 'path("m 10 20   l 20 30   Z   l 50 60   Z   m 70 80   l 90 60   Z   t 70 120")';
+    assert_equals(target.style.d, 'path("m 10 20 l 20 30 Z l 50 60 Z m 70 80 l 90 60 Z t 70 120")');
+    assert_equals(getComputedStyle(target).d, 'path("M 10 20 L 30 50 Z L 60 80 Z M 80 100 L 170 160 Z T 150 220")');
+
+    target.style.d = 'path("m 10.0 170.0 h 90.00 v 30.00 m 0 0 s 1 2 3 4 z c 9 8 7 6 5 4")';
+    assert_equals(target.style.d, 'path("m 10 170 h 90 v 30 m 0 0 s 1 2 3 4 Z c 9 8 7 6 5 4")');
+    assert_equals(getComputedStyle(target).d, 'path("M 10 170 H 100 V 200 M 100 200 S 101 202 103 204 Z C 109 208 107 206 105 204")');
+
+    target.style.d = '  path(  "m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50"  )  ';
+    assert_equals(target.style.d, 'path("m 10 20 a 10 20 30 1 0 40 50 a 110 120 30 1 1 140 50")');
+    assert_equals(getComputedStyle(target).d, 'path("M 10 20 A 10 20 30 1 0 50 70 A 110 120 30 1 1 190 120")');
+  });
+  ]]></script>
+</svg>