style: Simplify serialisation of BorderCornerRadius when possible.

Closes #18458.

Matches other browsers in test-cases like:

<div id="t" style="border-top-left-radius: 5px 5px"></div>
<script>alert(t.style.borderTopLeftRadius)</script>

(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 Rect<T>s and such, and
this is much easier).
This commit is contained in:
Emilio Cobos Álvarez 2017-09-15 17:58:36 +02:00
parent 6f97dd1c96
commit 4936314b7e
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 13 additions and 8 deletions

View file

@ -151,13 +151,18 @@ impl<L: Clone> From<L> for BorderCornerRadius<L> {
} }
impl<L> ToCss for BorderCornerRadius<L> impl<L> ToCss for BorderCornerRadius<L>
where L: ToCss, where L: ToCss + PartialEq,
{ {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write where W: fmt::Write
{ {
self.0.width.to_css(dest)?; 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(())
} }
} }

View file

@ -27301,7 +27301,7 @@
"testharness" "testharness"
], ],
"mozilla/calc.html": [ "mozilla/calc.html": [
"4f65929cacf623da2d3e310a6663d6165a1b0cdc", "2b6f029f2393830ea8dce5f26a5c9caaae65944f",
"testharness" "testharness"
], ],
"mozilla/canvas.initial.reset.2dstate.html": [ "mozilla/canvas.initial.reset.2dstate.html": [

View file

@ -146,10 +146,10 @@ var otherProperties = [
['perspective-origin', 'calc(1px + 0%)', 'calc(0% + 1px) center'], ['perspective-origin', 'calc(1px + 0%)', 'calc(0% + 1px) center'],
['background-size', 'calc(1px + 0%)', 'calc(0% + 1px) auto'], ['background-size', 'calc(1px + 0%)', 'calc(0% + 1px) auto'],
['background-position', 'calc(1px + 0%) calc(2px + 0%)', 'calc(0% + 1px) calc(0% + 2px)'], ['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-top-left-radius', 'calc(1px + 0%)', 'calc(0% + 1px)'],
['border-bottom-left-radius', 'calc(1px + 0%)', 'calc(0% + 1px) calc(0% + 1px)'], ['border-bottom-left-radius', 'calc(1px + 0%)', 'calc(0% + 1px)'],
['border-top-right-radius', 'calc(1px + 0%)', 'calc(0% + 1px) calc(0% + 1px)'], ['border-top-right-radius', 'calc(1px + 0%)', 'calc(0% + 1px)'],
['border-bottom-right-radius', 'calc(1px + 0%)', 'calc(0% + 1px) calc(0% + 1px)'], ['border-bottom-right-radius', 'calc(1px + 0%)', 'calc(0% + 1px)'],
['counter-increment', 'foo calc(1 + 1)', 'foo calc(2)'], ['counter-increment', 'foo calc(1 + 1)', 'foo calc(2)'],
]; ];