mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
parent
41e105733c
commit
c7871811c8
5 changed files with 81 additions and 55 deletions
|
@ -4,13 +4,14 @@
|
|||
|
||||
//! Computed types for box properties.
|
||||
|
||||
use values::computed::Number;
|
||||
use values::computed::{Context, Number, ToComputedValue};
|
||||
use values::computed::length::{LengthOrPercentage, NonNegativeLength};
|
||||
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
||||
use values::generics::box_::Perspective as GenericPerspective;
|
||||
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
|
||||
|
||||
pub use values::specified::box_::{AnimationName, Contain, Display, OverflowClipBox};
|
||||
pub use values::specified::box_::Float as SpecifiedFloat;
|
||||
pub use values::specified::box_::{OverscrollBehavior, ScrollSnapType, TouchAction, TransitionProperty, WillChange};
|
||||
|
||||
/// A computed value for the `vertical-align` property.
|
||||
|
@ -29,3 +30,56 @@ impl AnimationIterationCount {
|
|||
|
||||
/// A computed value for the `perspective` property.
|
||||
pub type Perspective = GenericPerspective<NonNegativeLength>;
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq,
|
||||
SpecifiedValueInfo, ToCss)]
|
||||
/// A computed value for the `float` property.
|
||||
pub enum Float {
|
||||
Left,
|
||||
Right,
|
||||
None
|
||||
}
|
||||
|
||||
impl ToComputedValue for SpecifiedFloat {
|
||||
type ComputedValue = Float;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||
let ltr = context.style().writing_mode.is_bidi_ltr();
|
||||
// https://drafts.csswg.org/css-logical-props/#float-clear
|
||||
match *self {
|
||||
SpecifiedFloat::InlineStart => {
|
||||
context.rule_cache_conditions.borrow_mut()
|
||||
.set_writing_mode_dependency(context.builder.writing_mode);
|
||||
if ltr {
|
||||
Float::Left
|
||||
} else {
|
||||
Float::Right
|
||||
}
|
||||
},
|
||||
SpecifiedFloat::InlineEnd => {
|
||||
context.rule_cache_conditions.borrow_mut()
|
||||
.set_writing_mode_dependency(context.builder.writing_mode);
|
||||
if ltr {
|
||||
Float::Right
|
||||
} else {
|
||||
Float::Left
|
||||
}
|
||||
},
|
||||
SpecifiedFloat::Left => Float::Left,
|
||||
SpecifiedFloat::Right => Float::Right,
|
||||
SpecifiedFloat::None => Float::None
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> SpecifiedFloat {
|
||||
match *computed {
|
||||
Float::Left => SpecifiedFloat::Left,
|
||||
Float::Right => SpecifiedFloat::Right,
|
||||
Float::None => SpecifiedFloat::None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue