зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #15178 - Fix serialization of CalcLengthOrPercentage (from canaltinova:calc); r=Wafflespeanut
<!-- Please describe your changes on the following line: --> --- <!-- 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 - [X] These changes fix #15168 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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: 5427e68572c034e6a12ca9766563bda88ee0c610
This commit is contained in:
Родитель
655fbcf0bd
Коммит
94969698a1
|
@ -761,20 +761,6 @@ impl HasViewportPercentage for CalcLengthOrPercentage {
|
|||
impl ToCss for CalcLengthOrPercentage {
|
||||
#[allow(unused_assignments)]
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
macro_rules! count {
|
||||
( $( $val:ident ),* ) => {
|
||||
{
|
||||
let mut count = 0;
|
||||
$(
|
||||
if let Some(_) = self.$val {
|
||||
count += 1;
|
||||
}
|
||||
)*
|
||||
count
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let mut first_value = true;
|
||||
macro_rules! first_value_check {
|
||||
() => {
|
||||
|
@ -798,12 +784,7 @@ impl ToCss for CalcLengthOrPercentage {
|
|||
};
|
||||
}
|
||||
|
||||
let count = count!(ch, em, ex, absolute, rem, vh, vmax, vmin, vw, percentage);
|
||||
assert!(count > 0);
|
||||
|
||||
if count > 1 {
|
||||
try!(write!(dest, "calc("));
|
||||
}
|
||||
try!(write!(dest, "calc("));
|
||||
|
||||
serialize!(ch, em, ex, rem, vh, vmax, vmin, vw);
|
||||
if let Some(val) = self.absolute {
|
||||
|
@ -816,11 +797,7 @@ impl ToCss for CalcLengthOrPercentage {
|
|||
try!(write!(dest, "{}%", val * 100.));
|
||||
}
|
||||
|
||||
if count > 1 {
|
||||
try!(write!(dest, ")"));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
write!(dest, ")")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче