mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Moved the rest of the longhand structs to separate files.
Sorry for the bulk size of this; I know already it's not going to be a fun thing to review. Nevertheless, it should be done so we finalize the split of this huge file into smaller, more maintable parts. The content of stuff being moved to separate files is unchanged. Only some minor formatting changes have been made and similar, but nothing of particular interest. IMHO it should be safe to merge if all the tests are fine.
This commit is contained in:
parent
97a45dc30c
commit
4e8831457a
21 changed files with 4440 additions and 4361 deletions
196
components/style/properties/longhand/column.mako.rs
Normal file
196
components/style/properties/longhand/column.mako.rs
Normal file
|
@ -0,0 +1,196 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||
|
||||
<% data.new_style_struct("Column", inherited=False, gecko_ffi_name="nsStyleColumn") %>
|
||||
|
||||
<%helpers:longhand name="column-width" experimental="True">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::AuExtensionMethods;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, HeapSizeOf)]
|
||||
pub enum SpecifiedValue {
|
||||
Auto,
|
||||
Specified(specified::Length),
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
SpecifiedValue::Auto => dest.write_str("auto"),
|
||||
SpecifiedValue::Specified(l) => l.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
use app_units::Au;
|
||||
#[derive(Debug, Clone, PartialEq, 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("auto"),
|
||||
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<Cx: TContext>(&self, context: &Cx) -> computed_value::T {
|
||||
match *self {
|
||||
SpecifiedValue::Auto => computed_value::T(None),
|
||||
SpecifiedValue::Specified(l) =>
|
||||
computed_value::T(Some(l.to_computed_value(context)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
||||
Ok(SpecifiedValue::Auto)
|
||||
} else {
|
||||
specified::Length::parse_non_negative(input).map(SpecifiedValue::Specified)
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
<%helpers:longhand name="column-count" experimental="True">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, HeapSizeOf)]
|
||||
pub enum SpecifiedValue {
|
||||
Auto,
|
||||
Specified(u32),
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
SpecifiedValue::Auto => dest.write_str("auto"),
|
||||
SpecifiedValue::Specified(count) => write!(dest, "{}", count),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
#[derive(Debug, Clone, PartialEq, HeapSizeOf)]
|
||||
pub struct T(pub Option<u32>);
|
||||
}
|
||||
|
||||
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("auto"),
|
||||
Some(count) => write!(dest, "{}", count),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[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<Cx: TContext>(&self, _context: &Cx) -> computed_value::T {
|
||||
match *self {
|
||||
SpecifiedValue::Auto => computed_value::T(None),
|
||||
SpecifiedValue::Specified(count) =>
|
||||
computed_value::T(Some(count))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if input.try(|input| input.expect_ident_matching("auto")).is_ok() {
|
||||
Ok(SpecifiedValue::Auto)
|
||||
} else {
|
||||
let count = try!(specified::parse_integer(input));
|
||||
// Zero is invalid
|
||||
if count <= 0 {
|
||||
return Err(())
|
||||
}
|
||||
Ok(SpecifiedValue::Specified(count as u32))
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
<%helpers:longhand name="column-gap" experimental="True">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::AuExtensionMethods;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, 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, 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<Cx: TContext>(&self, context: &Cx) -> computed_value::T {
|
||||
match *self {
|
||||
SpecifiedValue::Normal => computed_value::T(None),
|
||||
SpecifiedValue::Specified(l) =>
|
||||
computed_value::T(Some(l.to_computed_value(context)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
Loading…
Add table
Add a link
Reference in a new issue