From e978f11c9fec1dee43b2d1d3fc86c1161ef81ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Mon, 5 Dec 2016 23:05:38 +0300 Subject: [PATCH 1/2] Fix Keyframe selector serialization --- components/style/keyframes.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index 831627d42c3..474e4c8b539 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -14,7 +14,7 @@ use std::sync::Arc; use style_traits::ToCss; use stylesheets::{MemoryHoleReporter, Stylesheet}; -/// A number from 1 to 100, indicating the percentage of the animation where +/// A number from 0 to 1, indicating the percentage of the animation where /// this keyframe should run. #[derive(Debug, Copy, Clone, PartialEq, PartialOrd)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -30,6 +30,12 @@ impl ::std::cmp::Ord for KeyframePercentage { impl ::std::cmp::Eq for KeyframePercentage { } +impl ToCss for KeyframePercentage { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + write!(dest, "{}%", self.0 * 100.0) + } +} + impl KeyframePercentage { #[inline] pub fn new(value: f32) -> KeyframePercentage { @@ -93,10 +99,10 @@ pub struct Keyframe { impl ToCss for Keyframe { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { let mut iter = self.selector.percentages().iter(); - try!(write!(dest, "{}%", iter.next().unwrap().0)); + try!(iter.next().unwrap().to_css(dest)); for percentage in iter { try!(write!(dest, ", ")); - try!(write!(dest, "{}%", percentage.0)); + try!(percentage.to_css(dest)); } try!(dest.write_str(" { ")); try!(self.block.read().to_css(dest)); From 3b1de577f9bf54a83a7f598637dbd3b3d9b7b805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Tue, 6 Dec 2016 01:08:16 +0300 Subject: [PATCH 2/2] Write tests for CSSOM Interfaces --- tests/wpt/metadata/MANIFEST.json | 30 ++++++++++ .../cssom/CSSKeyframesRule.html | 58 +++++++++++++++++++ .../cssom/CSSNamespaceRule.html | 31 ++++++++++ .../web-platform-tests/cssom/CSSRuleList.html | 26 +++++++++ .../cssom/CSSStyleSheet.html | 43 ++++++++++++++ .../cssom/StyleSheetList.html | 33 +++++++++++ 6 files changed, 221 insertions(+) create mode 100644 tests/wpt/web-platform-tests/cssom/CSSKeyframesRule.html create mode 100644 tests/wpt/web-platform-tests/cssom/CSSNamespaceRule.html create mode 100644 tests/wpt/web-platform-tests/cssom/CSSRuleList.html create mode 100644 tests/wpt/web-platform-tests/cssom/CSSStyleSheet.html create mode 100644 tests/wpt/web-platform-tests/cssom/StyleSheetList.html diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 2176f9ef317..3e6746c6922 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -39677,12 +39677,42 @@ "deleted_reftests": {}, "items": { "testharness": { + "cssom/CSSKeyframesRule.html": [ + { + "path": "cssom/CSSKeyframesRule.html", + "url": "/cssom/CSSKeyframesRule.html" + } + ], + "cssom/CSSNamespaceRule.html": [ + { + "path": "cssom/CSSNamespaceRule.html", + "url": "/cssom/CSSNamespaceRule.html" + } + ], + "cssom/CSSRuleList.html": [ + { + "path": "cssom/CSSRuleList.html", + "url": "/cssom/CSSRuleList.html" + } + ], + "cssom/CSSStyleSheet.html": [ + { + "path": "cssom/CSSStyleSheet.html", + "url": "/cssom/CSSStyleSheet.html" + } + ], "cssom/MediaList.html": [ { "path": "cssom/MediaList.html", "url": "/cssom/MediaList.html" } ], + "cssom/StyleSheetList.html": [ + { + "path": "cssom/StyleSheetList.html", + "url": "/cssom/StyleSheetList.html" + } + ], "cssom/shorthand-serialization.html": [ { "path": "cssom/shorthand-serialization.html", diff --git a/tests/wpt/web-platform-tests/cssom/CSSKeyframesRule.html b/tests/wpt/web-platform-tests/cssom/CSSKeyframesRule.html new file mode 100644 index 00000000000..b97d988c9ac --- /dev/null +++ b/tests/wpt/web-platform-tests/cssom/CSSKeyframesRule.html @@ -0,0 +1,58 @@ + + + + + CSSOM - CSSKeyframesRule interface + + + + + + + diff --git a/tests/wpt/web-platform-tests/cssom/CSSNamespaceRule.html b/tests/wpt/web-platform-tests/cssom/CSSNamespaceRule.html new file mode 100644 index 00000000000..64ed94b6e7f --- /dev/null +++ b/tests/wpt/web-platform-tests/cssom/CSSNamespaceRule.html @@ -0,0 +1,31 @@ + + + + + CSSOM - CSSNamespaceRule interface + + + + + + + diff --git a/tests/wpt/web-platform-tests/cssom/CSSRuleList.html b/tests/wpt/web-platform-tests/cssom/CSSRuleList.html new file mode 100644 index 00000000000..a394779617d --- /dev/null +++ b/tests/wpt/web-platform-tests/cssom/CSSRuleList.html @@ -0,0 +1,26 @@ + + + + + CSSOM - CSSRuleList interface + + + + + + + diff --git a/tests/wpt/web-platform-tests/cssom/CSSStyleSheet.html b/tests/wpt/web-platform-tests/cssom/CSSStyleSheet.html new file mode 100644 index 00000000000..62ad133d5f6 --- /dev/null +++ b/tests/wpt/web-platform-tests/cssom/CSSStyleSheet.html @@ -0,0 +1,43 @@ + + + + + CSSOM - CSSStyleSheet interface + + + + + + + diff --git a/tests/wpt/web-platform-tests/cssom/StyleSheetList.html b/tests/wpt/web-platform-tests/cssom/StyleSheetList.html new file mode 100644 index 00000000000..358264009a4 --- /dev/null +++ b/tests/wpt/web-platform-tests/cssom/StyleSheetList.html @@ -0,0 +1,33 @@ + + + + + CSSOM - StyleSheetList interface + + + + + + +