mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Add a Zero trait that doesn't require Add, and use it in place of num_traits and IsZeroLength.
Use it to be consistent in InsetRect serialization and storage between Servo and Gecko. Differential Revision: https://phabricator.services.mozilla.com/D21493
This commit is contained in:
parent
4496411edc
commit
7d01114cbf
29 changed files with 179 additions and 186 deletions
|
@ -5,6 +5,7 @@
|
|||
//! Generic type for CSS properties that are composed by two dimensions.
|
||||
|
||||
use crate::parser::ParserContext;
|
||||
use crate::Zero;
|
||||
use cssparser::Parser;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
|
@ -84,3 +85,13 @@ where
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<L: Zero> Zero for Size2D<L> {
|
||||
fn zero() -> Self {
|
||||
Self::new(L::zero(), L::zero())
|
||||
}
|
||||
|
||||
fn is_zero(&self) -> bool {
|
||||
self.width.is_zero() && self.height.is_zero()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue