mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #14464 - canaltinova:cssom-test, r=Manishearth
Write tests for CSSOM Interfaces <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14464) <!-- Reviewable:end -->
This commit is contained in:
commit
8dfaed2183
7 changed files with 230 additions and 3 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue