mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 16:55:40 +00:00
servo: Merge #14464 - Write tests for CSSOM Interfaces (from canaltinova:cssom-test); r=Manishearth
<!-- Please describe your changes on the following line: --> ToCss implementation was wrong about Keyframe percentage values, it was writing values between 0-1. I had to fix it. Wrote some tests about CSSKeyframesRule, CSSNamespaceRule, CSSRuleList, CSSStyleSheet, StyleSheetList interfaces. CSSFontFaceRule and CSSViewportRule looks like not implemented yet. I didn't write one for them. Also name attribute in CSSKeyframesRule isn't implemented yet. Is there any complication about it? If not, I can implement it. r? @Manishearth --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 8dfaed218377dbac6935b54f1599d7a9245d6122
This commit is contained in:
parent
bfad4fc22b
commit
a7808a60f8
@ -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<W>(&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<W>(&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));
|
||||
|
Loading…
Reference in New Issue
Block a user