mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
style: Align border-spacing with other engines.
This commit is contained in:
parent
8205a0de90
commit
35496c8ae1
2 changed files with 21 additions and 14 deletions
|
@ -496,8 +496,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::BorderSpacing(
|
PropertyDeclaration::BorderSpacing(
|
||||||
Box::new(border_spacing::SpecifiedValue {
|
Box::new(border_spacing::SpecifiedValue {
|
||||||
horizontal: width_value.clone(),
|
horizontal: width_value,
|
||||||
vertical: width_value,
|
vertical: None,
|
||||||
}))));
|
}))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
||||||
|
|
||||||
impl HasViewportPercentage for SpecifiedValue {
|
impl HasViewportPercentage for SpecifiedValue {
|
||||||
fn has_viewport_percentage(&self) -> bool {
|
fn has_viewport_percentage(&self) -> bool {
|
||||||
return self.horizontal.has_viewport_percentage() || self.vertical.has_viewport_percentage()
|
self.horizontal.has_viewport_percentage() ||
|
||||||
|
self.vertical.as_ref().map_or(false, |v| v.has_viewport_percentage())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct SpecifiedValue {
|
pub struct SpecifiedValue {
|
||||||
pub horizontal: specified::Length,
|
pub horizontal: specified::Length,
|
||||||
pub vertical: specified::Length,
|
pub vertical: Option<specified::Length>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -72,10 +73,15 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToCss for SpecifiedValue {
|
impl ToCss for SpecifiedValue {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||||
|
where W: fmt::Write,
|
||||||
|
{
|
||||||
try!(self.horizontal.to_css(dest));
|
try!(self.horizontal.to_css(dest));
|
||||||
try!(dest.write_str(" "));
|
if let Some(vertical) = self.vertical.as_ref() {
|
||||||
self.vertical.to_css(dest)
|
try!(dest.write_str(" "));
|
||||||
|
vertical.to_css(dest)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,9 +98,10 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
||||||
|
let horizontal = self.horizontal.to_computed_value(context);
|
||||||
computed_value::T {
|
computed_value::T {
|
||||||
horizontal: self.horizontal.to_computed_value(context),
|
horizontal: horizontal,
|
||||||
vertical: self.vertical.to_computed_value(context),
|
vertical: self.vertical.as_ref().map_or(horizontal, |v| v.to_computed_value(context)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +109,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
||||||
fn from_computed_value(computed: &computed_value::T) -> Self {
|
fn from_computed_value(computed: &computed_value::T) -> Self {
|
||||||
SpecifiedValue {
|
SpecifiedValue {
|
||||||
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
|
horizontal: ToComputedValue::from_computed_value(&computed.horizontal),
|
||||||
vertical: ToComputedValue::from_computed_value(&computed.vertical),
|
vertical: Some(ToComputedValue::from_computed_value(&computed.vertical)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,17 +130,17 @@ ${helpers.single_keyword("caption-side", "top bottom",
|
||||||
(None, None) => Err(()),
|
(None, None) => Err(()),
|
||||||
(Some(length), None) => {
|
(Some(length), None) => {
|
||||||
Ok(SpecifiedValue {
|
Ok(SpecifiedValue {
|
||||||
horizontal: length.clone(),
|
horizontal: length,
|
||||||
vertical: length,
|
vertical: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(Some(horizontal), Some(vertical)) => {
|
(Some(horizontal), Some(vertical)) => {
|
||||||
Ok(SpecifiedValue {
|
Ok(SpecifiedValue {
|
||||||
horizontal: horizontal,
|
horizontal: horizontal,
|
||||||
vertical: vertical,
|
vertical: Some(vertical),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
(None, Some(_)) => panic!("shouldn't happen"),
|
(None, Some(_)) => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue