aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor Brewster <connor.brewster@eagles.oc.edu>2017-11-08 14:34:31 -0600
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-12-14 03:43:10 +0100
commit16f627a18a79b50ae3dd7a1398454703d4a9e6f9 (patch)
tree24a6ab5bd4907961c5a5a070ebce6b210cd17b9a
parent714c1b2455bc6f651e982b5efec85e3bf711f708 (diff)
downloadservo-16f627a18a79b50ae3dd7a1398454703d4a9e6f9.tar.gz
servo-16f627a18a79b50ae3dd7a1398454703d4a9e6f9.zip
style: Move list quotes out of mako
-rw-r--r--components/style/properties/longhand/list.mako.rs75
-rw-r--r--components/style/values/computed/list.rs18
-rw-r--r--components/style/values/computed/mod.rs2
-rw-r--r--components/style/values/specified/list.rs64
-rw-r--r--components/style/values/specified/mod.rs2
5 files changed, 91 insertions, 70 deletions
diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs
index 4f3442da376..363f2a926c5 100644
--- a/components/style/properties/longhand/list.mako.rs
+++ b/components/style/properties/longhand/list.mako.rs
@@ -135,76 +135,11 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
}
</%helpers:longhand>
-<%helpers:longhand name="quotes" animation_value_type="discrete"
- spec="https://drafts.csswg.org/css-content/#propdef-quotes">
- use cssparser::serialize_string;
- use std::fmt;
- use style_traits::ToCss;
-
- pub use self::computed_value::T as SpecifiedValue;
-
- pub mod computed_value {
- #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
- pub struct T(pub Vec<(String, String)>);
- }
-
- impl ToCss for SpecifiedValue {
- fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- if self.0.is_empty() {
- return dest.write_str("none")
- }
-
- let mut first = true;
- for pair in &self.0 {
- if !first {
- dest.write_str(" ")?;
- }
- first = false;
- serialize_string(&*pair.0, dest)?;
- dest.write_str(" ")?;
- serialize_string(&*pair.1, dest)?;
- }
- Ok(())
- }
- }
-
- #[inline]
- pub fn get_initial_value() -> computed_value::T {
- computed_value::T(vec![
- ("\u{201c}".to_owned(), "\u{201d}".to_owned()),
- ("\u{2018}".to_owned(), "\u{2019}".to_owned()),
- ])
- }
-
- pub fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>)
- -> Result<SpecifiedValue,ParseError<'i>> {
- if input.try(|input| input.expect_ident_matching("none")).is_ok() {
- return Ok(SpecifiedValue(Vec::new()))
- }
-
- let mut quotes = Vec::new();
- loop {
- let location = input.current_source_location();
- let first = match input.next() {
- Ok(&Token::QuotedString(ref value)) => value.as_ref().to_owned(),
- Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
- Err(_) => break,
- };
- let location = input.current_source_location();
- let second = match input.next() {
- Ok(&Token::QuotedString(ref value)) => value.as_ref().to_owned(),
- Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
- Err(e) => return Err(e.into()),
- };
- quotes.push((first, second))
- }
- if !quotes.is_empty() {
- Ok(SpecifiedValue(quotes))
- } else {
- Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
- }
- }
-</%helpers:longhand>
+${helpers.predefined_type("quotes",
+ "Quotes",
+ "computed::Quotes::get_initial_value()",
+ animation_value_type="discrete",
+ spec="https://drafts.csswg.org/css-content/#propdef-quotes")}
${helpers.predefined_type("-moz-image-region",
"ClipRectOrAuto",
diff --git a/components/style/values/computed/list.rs b/components/style/values/computed/list.rs
new file mode 100644
index 00000000000..5dcba715cc5
--- /dev/null
+++ b/components/style/values/computed/list.rs
@@ -0,0 +1,18 @@
+/* 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/. */
+
+//! `list` computed values.
+
+pub use values::specified::list::Quotes;
+
+impl Quotes {
+ /// Initial value for `quotes`
+ #[inline]
+ pub fn get_initial_value() -> Quotes {
+ Quotes(vec![
+ ("\u{201c}".to_owned(), "\u{201d}".to_owned()),
+ ("\u{2018}".to_owned(), "\u{2019}".to_owned()),
+ ])
+ }
+}
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index 3f2388698fe..36c750dc963 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -54,6 +54,7 @@ pub use super::specified::{BorderStyle, TextDecorationLine};
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNone, LengthOrNumber, LengthOrPercentage};
pub use self::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, MaxLength, MozLength};
pub use self::length::{CSSPixelLength, NonNegativeLength, NonNegativeLengthOrPercentage};
+pub use self::list::Quotes;
pub use self::outline::OutlineStyle;
pub use self::percentage::Percentage;
pub use self::position::{Position, GridAutoFlow, GridTemplateAreas};
@@ -80,6 +81,7 @@ pub mod image;
#[cfg(feature = "gecko")]
pub mod gecko;
pub mod length;
+pub mod list;
pub mod outline;
pub mod percentage;
pub mod position;
diff --git a/components/style/values/specified/list.rs b/components/style/values/specified/list.rs
new file mode 100644
index 00000000000..68c894b97e5
--- /dev/null
+++ b/components/style/values/specified/list.rs
@@ -0,0 +1,64 @@
+/* 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/. */
+
+//! `list` specified values.
+
+use cssparser::{Parser, Token, serialize_string};
+use parser::{Parse, ParserContext};
+use std::fmt;
+use style_traits::{ParseError, StyleParseErrorKind, ToCss};
+
+/// Specified and computed `quote` property
+#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)]
+pub struct Quotes(pub Vec<(String, String)>);
+
+impl ToCss for Quotes {
+ fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
+ if self.0.is_empty() {
+ return dest.write_str("none")
+ }
+
+ let mut first = true;
+ for pair in &self.0 {
+ if !first {
+ dest.write_str(" ")?;
+ }
+ first = false;
+ serialize_string(&*pair.0, dest)?;
+ dest.write_str(" ")?;
+ serialize_string(&*pair.1, dest)?;
+ }
+ Ok(())
+ }
+}
+
+impl Parse for Quotes {
+ fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Quotes, ParseError<'i>> {
+ if input.try(|input| input.expect_ident_matching("none")).is_ok() {
+ return Ok(Quotes(Vec::new()))
+ }
+
+ let mut quotes = Vec::new();
+ loop {
+ let location = input.current_source_location();
+ let first = match input.next() {
+ Ok(&Token::QuotedString(ref value)) => value.as_ref().to_owned(),
+ Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
+ Err(_) => break,
+ };
+ let location = input.current_source_location();
+ let second = match input.next() {
+ Ok(&Token::QuotedString(ref value)) => value.as_ref().to_owned(),
+ Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
+ Err(e) => return Err(e.into()),
+ };
+ quotes.push((first, second))
+ }
+ if !quotes.is_empty() {
+ Ok(Quotes(quotes))
+ } else {
+ Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
+ }
+ }
+}
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index d9863620ae4..cb346728ad0 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -49,6 +49,7 @@ pub use self::length::{LengthOrPercentage, LengthOrPercentageOrAuto};
pub use self::length::{LengthOrPercentageOrNone, MaxLength, MozLength};
pub use self::length::{NoCalcLength, ViewportPercentageLength};
pub use self::length::NonNegativeLengthOrPercentage;
+pub use self::list::Quotes;
pub use self::outline::OutlineStyle;
pub use self::rect::LengthOrNumberRect;
pub use self::percentage::Percentage;
@@ -79,6 +80,7 @@ pub mod gecko;
pub mod grid;
pub mod image;
pub mod length;
+pub mod list;
pub mod outline;
pub mod percentage;
pub mod position;