mirror of
https://github.com/servo/servo.git
synced 2025-06-29 11:33:39 +01:00
Computed value for TrackBreadth and TrackSize
This commit is contained in:
parent
76d4a48885
commit
b55cc7f9da
2 changed files with 53 additions and 3 deletions
|
@ -2,14 +2,14 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
//! A grid line type.
|
//! Necessary types for [grid](https://drafts.csswg.org/css-grid/).
|
||||||
|
|
||||||
use cssparser::{Parser, Token};
|
use cssparser::{Parser, Token};
|
||||||
use parser::{Parse, ParserContext};
|
use parser::{Parse, ParserContext};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use values::{CSSFloat, HasViewportPercentage};
|
use values::{CSSFloat, HasViewportPercentage};
|
||||||
use values::computed::ComputedValueAsSpecified;
|
use values::computed::{ComputedValueAsSpecified, Context, ToComputedValue};
|
||||||
use values::specified::LengthOrPercentage;
|
use values::specified::LengthOrPercentage;
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug)]
|
#[derive(PartialEq, Clone, Debug)]
|
||||||
|
@ -159,6 +159,29 @@ impl HasViewportPercentage for TrackBreadth<LengthOrPercentage> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<L: ToComputedValue> ToComputedValue for TrackBreadth<L> {
|
||||||
|
type ComputedValue = TrackBreadth<L::ComputedValue>;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||||
|
match *self {
|
||||||
|
TrackBreadth::Breadth(ref lop) => TrackBreadth::Breadth(lop.to_computed_value(context)),
|
||||||
|
TrackBreadth::Flex(fr) => TrackBreadth::Flex(fr),
|
||||||
|
TrackBreadth::Keyword(k) => TrackBreadth::Keyword(k),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||||
|
match *computed {
|
||||||
|
TrackBreadth::Breadth(ref lop) =>
|
||||||
|
TrackBreadth::Breadth(ToComputedValue::from_computed_value(lop)),
|
||||||
|
TrackBreadth::Flex(fr) => TrackBreadth::Flex(fr),
|
||||||
|
TrackBreadth::Keyword(k) => TrackBreadth::Keyword(k),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
@ -229,3 +252,30 @@ impl HasViewportPercentage for TrackSize<LengthOrPercentage> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
|
||||||
|
type ComputedValue = TrackSize<L::ComputedValue>;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||||
|
match *self {
|
||||||
|
TrackSize::Breadth(ref b) => TrackSize::Breadth(b.to_computed_value(context)),
|
||||||
|
TrackSize::MinMax(ref b_1, ref b_2) =>
|
||||||
|
TrackSize::MinMax(b_1.to_computed_value(context), b_2.to_computed_value(context)),
|
||||||
|
TrackSize::FitContent(ref lop) => TrackSize::FitContent(lop.to_computed_value(context)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||||
|
match *computed {
|
||||||
|
TrackSize::Breadth(ref b) =>
|
||||||
|
TrackSize::Breadth(ToComputedValue::from_computed_value(b)),
|
||||||
|
TrackSize::MinMax(ref b_1, ref b_2) =>
|
||||||
|
TrackSize::MinMax(ToComputedValue::from_computed_value(b_1),
|
||||||
|
ToComputedValue::from_computed_value(b_2)),
|
||||||
|
TrackSize::FitContent(ref lop) =>
|
||||||
|
TrackSize::FitContent(ToComputedValue::from_computed_value(lop)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ use super::computed::Shadow as ComputedShadow;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
|
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
|
||||||
pub use self::grid::GridLine;
|
pub use self::grid::{GridLine, TrackBreadth, TrackKeyword, TrackSize};
|
||||||
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
||||||
pub use self::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
|
pub use self::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
|
||||||
pub use self::image::{SizeKeyword, VerticalDirection};
|
pub use self::image::{SizeKeyword, VerticalDirection};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue