From 4936314b7e9f13c5447c151992063bef1af48f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 15 Sep 2017 17:58:36 +0200 Subject: [PATCH] style: Simplify serialisation of BorderCornerRadius when possible. Closes #18458. Matches other browsers in test-cases like:
(I think it'd be nicer to preserve the original value completely, but not going to complain given we already do this for all sorts of Rects and such, and this is much easier). --- components/style/values/generics/border.rs | 11 ++++++++--- tests/wpt/mozilla/meta/MANIFEST.json | 2 +- tests/wpt/mozilla/tests/mozilla/calc.html | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/components/style/values/generics/border.rs b/components/style/values/generics/border.rs index 33f9cd8b8a6..215c2fd23e5 100644 --- a/components/style/values/generics/border.rs +++ b/components/style/values/generics/border.rs @@ -151,13 +151,18 @@ impl From for BorderCornerRadius { } impl ToCss for BorderCornerRadius - where L: ToCss, + where L: ToCss + PartialEq, { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { self.0.width.to_css(dest)?; - dest.write_str(" ")?; - self.0.height.to_css(dest) + + if self.0.height != self.0.width { + dest.write_str(" ")?; + self.0.height.to_css(dest)?; + } + + Ok(()) } } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index a451a31a9c2..7c4260ca22f 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -27301,7 +27301,7 @@ "testharness" ], "mozilla/calc.html": [ - "4f65929cacf623da2d3e310a6663d6165a1b0cdc", + "2b6f029f2393830ea8dce5f26a5c9caaae65944f", "testharness" ], "mozilla/canvas.initial.reset.2dstate.html": [ diff --git a/tests/wpt/mozilla/tests/mozilla/calc.html b/tests/wpt/mozilla/tests/mozilla/calc.html index 6f2a77a1d4f..2408f196c00 100644 --- a/tests/wpt/mozilla/tests/mozilla/calc.html +++ b/tests/wpt/mozilla/tests/mozilla/calc.html @@ -146,10 +146,10 @@ var otherProperties = [ ['perspective-origin', 'calc(1px + 0%)', 'calc(0% + 1px) center'], ['background-size', 'calc(1px + 0%)', 'calc(0% + 1px) auto'], ['background-position', 'calc(1px + 0%) calc(2px + 0%)', 'calc(0% + 1px) calc(0% + 2px)'], - ['border-top-left-radius', 'calc(1px + 0%)', 'calc(0% + 1px) calc(0% + 1px)'], - ['border-bottom-left-radius', 'calc(1px + 0%)', 'calc(0% + 1px) calc(0% + 1px)'], - ['border-top-right-radius', 'calc(1px + 0%)', 'calc(0% + 1px) calc(0% + 1px)'], - ['border-bottom-right-radius', 'calc(1px + 0%)', 'calc(0% + 1px) calc(0% + 1px)'], + ['border-top-left-radius', 'calc(1px + 0%)', 'calc(0% + 1px)'], + ['border-bottom-left-radius', 'calc(1px + 0%)', 'calc(0% + 1px)'], + ['border-top-right-radius', 'calc(1px + 0%)', 'calc(0% + 1px)'], + ['border-bottom-right-radius', 'calc(1px + 0%)', 'calc(0% + 1px)'], ['counter-increment', 'foo calc(1 + 1)', 'foo calc(2)'], ];