mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
servo: Merge #14538 - Use LengthOrNormal for column-gap #14297 (from DominoTree:master); r=Manishearth,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 #14297 (github issue number if applicable). <!-- Either: --> - [ ] 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: 0530e648af9ff01ada4b7a5fa4a43d608b8602db
This commit is contained in:
parent
be4b6521fe
commit
40866dde40
@ -99,9 +99,11 @@ impl Flow for MulticolFlow {
|
||||
{
|
||||
let column_style = self.block_flow.fragment.style.get_column();
|
||||
|
||||
// `None` is 'normal': "UA-specified length. A value of 1em is suggested."
|
||||
let column_gap = column_style.column_gap.0.unwrap_or_else(||
|
||||
self.block_flow.fragment.style.get_font().font_size);
|
||||
let column_gap = match column_style.column_gap {
|
||||
Either::First(len) => len,
|
||||
Either::Second(_normal) => self.block_flow.fragment.style.get_font().font_size,
|
||||
};
|
||||
|
||||
let mut column_count;
|
||||
if let Either::First(column_width) = column_style.column_width {
|
||||
column_count =
|
||||
|
@ -2387,9 +2387,11 @@ clip-path
|
||||
${impl_simple_copy('column_count', 'mColumnCount')}
|
||||
|
||||
pub fn set_column_gap(&mut self, v: longhands::column_gap::computed_value::T) {
|
||||
match v.0 {
|
||||
Some(len) => self.gecko.mColumnGap.set(len),
|
||||
None => self.gecko.mColumnGap.set_value(CoordDataValue::Normal),
|
||||
use values::Either;
|
||||
|
||||
match v {
|
||||
Either::First(len) => self.gecko.mColumnGap.set(len),
|
||||
Either::Second(_normal) => self.gecko.mColumnGap.set_value(CoordDataValue::Normal),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,86 +96,12 @@ ${helpers.predefined_type("column-width",
|
||||
</%helpers:longhand>
|
||||
|
||||
// FIXME: This prop should be animatable.
|
||||
<%helpers:longhand name="column-gap" experimental="True" animatable="False">
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
impl HasViewportPercentage for SpecifiedValue {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
SpecifiedValue::Specified(length) => length.has_viewport_percentage(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum SpecifiedValue {
|
||||
Normal,
|
||||
Specified(specified::Length),
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
SpecifiedValue::Normal => dest.write_str("normal"),
|
||||
SpecifiedValue::Specified(l) => l.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
use app_units::Au;
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct T(pub Option<Au>);
|
||||
}
|
||||
|
||||
impl ToCss for computed_value::T {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match self.0 {
|
||||
None => dest.write_str("normal"),
|
||||
Some(l) => l.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
computed_value::T(None)
|
||||
}
|
||||
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
type ComputedValue = computed_value::T;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
||||
match *self {
|
||||
SpecifiedValue::Normal => computed_value::T(None),
|
||||
SpecifiedValue::Specified(l) =>
|
||||
computed_value::T(Some(l.to_computed_value(context)))
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &computed_value::T) -> Self {
|
||||
match *computed {
|
||||
computed_value::T(None) => SpecifiedValue::Normal,
|
||||
computed_value::T(Some(l)) =>
|
||||
SpecifiedValue::Specified(ToComputedValue::from_computed_value(&l))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
|
||||
Ok(SpecifiedValue::Normal)
|
||||
} else {
|
||||
specified::Length::parse_non_negative(input).map(SpecifiedValue::Specified)
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
${helpers.predefined_type("column-gap",
|
||||
"length::LengthOrNormal",
|
||||
"Either::Second(Normal)",
|
||||
parse_method='parse_non_negative_length',
|
||||
experimental=True,
|
||||
animatable=False)}
|
||||
|
||||
${helpers.single_keyword("column-fill", "auto balance",
|
||||
products="gecko", animatable=False)}
|
||||
|
@ -7,7 +7,7 @@ use ordered_float::NotNaN;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use super::{Number, ToComputedValue, Context};
|
||||
use values::{Auto, CSSFloat, Either, None_, specified};
|
||||
use values::{Auto, CSSFloat, Either, None_, Normal, specified};
|
||||
|
||||
pub use cssparser::Color as CSSColor;
|
||||
pub use super::image::{EndingShape as GradientShape, Gradient, GradientKind, Image};
|
||||
@ -475,4 +475,6 @@ pub type LengthOrAuto = Either<Length, Auto>;
|
||||
|
||||
pub type LengthOrNumber = Either<Length, Number>;
|
||||
|
||||
pub type LengthOrNormal = Either<Length, Normal>;
|
||||
|
||||
pub type Length = Au;
|
||||
|
@ -14,7 +14,7 @@ use std::ops::Mul;
|
||||
use style_traits::ToCss;
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
use super::{Angle, Number, SimplifiedValueNode, SimplifiedSumNode, Time};
|
||||
use values::{Auto, CSSFloat, Either, FONT_MEDIUM_PX, HasViewportPercentage, None_};
|
||||
use values::{Auto, CSSFloat, Either, FONT_MEDIUM_PX, HasViewportPercentage, None_, Normal};
|
||||
use values::computed::Context;
|
||||
|
||||
pub use super::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
|
||||
@ -952,6 +952,8 @@ impl Parse for LengthOrPercentageOrNone {
|
||||
|
||||
pub type LengthOrNone = Either<Length, None_>;
|
||||
|
||||
pub type LengthOrNormal = Either<Length, Normal>;
|
||||
|
||||
pub type LengthOrAuto = Either<Length, Auto>;
|
||||
|
||||
#[derive(Clone, PartialEq, Copy, Debug)]
|
||||
|
Loading…
Reference in New Issue
Block a user