mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
auto merge of #4455 : servo/servo/to_css, r=jdm
See https://github.com/servo/rust-cssparser/pull/67 and https://github.com/servo/servo/issues/4440. r? @jdm
This commit is contained in:
commit
b3059ee85b
13 changed files with 341 additions and 279 deletions
|
@ -50,3 +50,22 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
reg.register_lint_pass(box lints::InheritancePass as LintPassObject);
|
reg.register_lint_pass(box lints::InheritancePass as LintPassObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! match_ignore_ascii_case {
|
||||||
|
( $value: expr: $( $string: expr => $result: expr ),+ _ => $fallback: expr, ) => {
|
||||||
|
match_ignore_ascii_case! { $value:
|
||||||
|
$( $string => $result ),+
|
||||||
|
_ => $fallback
|
||||||
|
}
|
||||||
|
};
|
||||||
|
( $value: expr: $( $string: expr => $result: expr ),+ _ => $fallback: expr ) => {
|
||||||
|
{
|
||||||
|
use std::ascii::AsciiExt;
|
||||||
|
match $value.as_slice() {
|
||||||
|
$( s if s.eq_ignore_ascii_case($string) => $result, )+
|
||||||
|
_ => $fallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -104,8 +104,8 @@ fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
|
||||||
// Determines if a block is in an unsafe context so that an unhelpful
|
// Determines if a block is in an unsafe context so that an unhelpful
|
||||||
// lint can be aborted.
|
// lint can be aborted.
|
||||||
fn unsafe_context(map: &ast_map::Map, id: ast::NodeId) -> bool {
|
fn unsafe_context(map: &ast_map::Map, id: ast::NodeId) -> bool {
|
||||||
match map.get(map.get_parent(id)) {
|
match map.find(map.get_parent(id)) {
|
||||||
ast_map::NodeImplItem(itm) => {
|
Some(ast_map::NodeImplItem(itm)) => {
|
||||||
match *itm {
|
match *itm {
|
||||||
ast::MethodImplItem(ref meth) => match meth.node {
|
ast::MethodImplItem(ref meth) => match meth.node {
|
||||||
ast::MethDecl(_, _, _, _, style, _, _, _) => match style {
|
ast::MethDecl(_, _, _, _, style, _, _, _) => match style {
|
||||||
|
@ -117,7 +117,7 @@ fn unsafe_context(map: &ast_map::Map, id: ast::NodeId) -> bool {
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ast_map::NodeItem(itm) => {
|
Some(ast_map::NodeItem(itm)) => {
|
||||||
match itm.node {
|
match itm.node {
|
||||||
ast::ItemFn(_, style, _, _, _) => match style {
|
ast::ItemFn(_, style, _, _, _) => match style {
|
||||||
ast::UnsafeFn => true,
|
ast::UnsafeFn => true,
|
||||||
|
|
11
components/servo/Cargo.lock
generated
11
components/servo/Cargo.lock
generated
|
@ -124,9 +124,10 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cssparser"
|
name = "cssparser"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-cssparser#97d8c3b20a240881573748d4eadcda610bfb888c"
|
source = "git+https://github.com/servo/rust-cssparser#a2b0b6b00ad84dc3a4b4faf77ddd63611c8ce58a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)",
|
"encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -673,6 +674,7 @@ dependencies = [
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
@ -681,6 +683,11 @@ dependencies = [
|
||||||
name = "task_info"
|
name = "task_info"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "text_writer"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -706,9 +713,11 @@ dependencies = [
|
||||||
"cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)",
|
"cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)",
|
||||||
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
|
||||||
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
"layers 0.1.0 (git+https://github.com/servo/rust-layers)",
|
||||||
|
"plugins 0.0.1",
|
||||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"task_info 0.0.1",
|
"task_info 0.0.1",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.0 (git+https://github.com/rust-lang/time)",
|
"time 0.1.0 (git+https://github.com/rust-lang/time)",
|
||||||
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
||||||
]
|
]
|
||||||
|
|
|
@ -36,3 +36,5 @@ git = "https://github.com/servo/string-cache"
|
||||||
[dependencies.string_cache_macros]
|
[dependencies.string_cache_macros]
|
||||||
git = "https://github.com/servo/string-cache"
|
git = "https://github.com/servo/string-cache"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
text_writer = "0.1.1"
|
||||||
|
|
|
@ -18,6 +18,7 @@ extern crate collections;
|
||||||
extern crate geom;
|
extern crate geom;
|
||||||
extern crate serialize;
|
extern crate serialize;
|
||||||
extern crate sync;
|
extern crate sync;
|
||||||
|
extern crate text_writer;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
||||||
extern crate cssparser;
|
extern crate cssparser;
|
||||||
|
@ -27,6 +28,9 @@ extern crate string_cache;
|
||||||
#[phase(plugin)]
|
#[phase(plugin)]
|
||||||
extern crate string_cache_macros;
|
extern crate string_cache_macros;
|
||||||
|
|
||||||
|
#[phase(plugin)]
|
||||||
|
extern crate plugins;
|
||||||
|
|
||||||
#[phase(plugin)]
|
#[phase(plugin)]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
|
|
@ -3,22 +3,69 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
#![macro_escape]
|
||||||
|
|
||||||
use url::{Url, UrlParser};
|
use url::{Url, UrlParser};
|
||||||
|
|
||||||
pub use servo_util::geometry::Au;
|
pub use servo_util::geometry::Au;
|
||||||
|
|
||||||
|
|
||||||
|
macro_rules! define_css_keyword_enum {
|
||||||
|
($name: ident: $( $css: expr => $variant: ident ),+,) => {
|
||||||
|
define_css_keyword_enum!($name: $( $css => $variant ),+)
|
||||||
|
};
|
||||||
|
($name: ident: $( $css: expr => $variant: ident ),+) => {
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
#[deriving(Clone, Eq, PartialEq, FromPrimitive)]
|
||||||
|
pub enum $name {
|
||||||
|
$( $variant ),+
|
||||||
|
}
|
||||||
|
|
||||||
|
impl $name {
|
||||||
|
pub fn parse(component_value: &::cssparser::ast::ComponentValue) -> Result<$name, ()> {
|
||||||
|
match component_value {
|
||||||
|
&::cssparser::ast::Ident(ref value) => {
|
||||||
|
match_ignore_ascii_case! { value:
|
||||||
|
$( $css => Ok($name::$variant) ),+
|
||||||
|
_ => Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::std::fmt::Show for $name {
|
||||||
|
#[inline]
|
||||||
|
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||||
|
use cssparser::ToCss;
|
||||||
|
self.fmt_to_css(f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ::cssparser::ToCss for $name {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> ::text_writer::Result
|
||||||
|
where W: ::text_writer::TextWriter {
|
||||||
|
match self {
|
||||||
|
$( &$name::$variant => dest.write_str($css) ),+
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub type CSSFloat = f64;
|
pub type CSSFloat = f64;
|
||||||
|
|
||||||
pub mod specified {
|
pub mod specified {
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::f64::consts::PI;
|
use std::f64::consts::PI;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::{Formatter, FormatError, Show};
|
use std::fmt::{Formatter, Show};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use cssparser;
|
use cssparser::{mod, ast, ToCss, CssStringWriter};
|
||||||
use cssparser::ast;
|
|
||||||
use cssparser::ast::*;
|
use cssparser::ast::*;
|
||||||
|
use text_writer::{mod, TextWriter};
|
||||||
use parsing_utils::{mod, BufferedIter, ParserIter};
|
use parsing_utils::{mod, BufferedIter, ParserIter};
|
||||||
use super::{Au, CSSFloat};
|
use super::{Au, CSSFloat};
|
||||||
|
|
||||||
|
@ -42,11 +89,16 @@ pub mod specified {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for CSSColor {
|
impl fmt::Show for CSSColor {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for CSSColor {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
match self.authored {
|
match self.authored {
|
||||||
Some(ref s) => write!(f, "{}", s),
|
Some(ref s) => dest.write_str(s.as_slice()),
|
||||||
None => write!(f, "{}", self.parsed),
|
None => self.parsed.to_css(dest),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,22 +109,30 @@ pub mod specified {
|
||||||
pub authored: Option<String>,
|
pub authored: Option<String>,
|
||||||
}
|
}
|
||||||
impl fmt::Show for CSSRGBA {
|
impl fmt::Show for CSSRGBA {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for CSSRGBA {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
match self.authored {
|
match self.authored {
|
||||||
Some(ref s) => write!(f, "{}", s),
|
Some(ref s) => dest.write_str(s.as_slice()),
|
||||||
None => write!(f, "{}", self.parsed),
|
None => self.parsed.to_css(dest),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, PartialEq)]
|
#[deriving(Clone, PartialEq)]
|
||||||
pub struct CSSImage(pub Option<Image>);
|
pub struct CSSImage(pub Option<Image>);
|
||||||
|
|
||||||
impl fmt::Show for CSSImage {
|
impl fmt::Show for CSSImage {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
let &CSSImage(ref url) = self;
|
}
|
||||||
match url {
|
|
||||||
&Some(ref image) => write!(f, "{}", image),
|
impl ToCss for CSSImage {
|
||||||
&None => write!(f, "none"),
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
|
match self {
|
||||||
|
&CSSImage(Some(ref image)) => image.to_css(dest),
|
||||||
|
&CSSImage(None) => dest.write_str("none"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,17 +157,24 @@ pub mod specified {
|
||||||
// Vmin(CSSFloat),
|
// Vmin(CSSFloat),
|
||||||
// Vmax(CSSFloat),
|
// Vmax(CSSFloat),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for Length {
|
impl fmt::Show for Length {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for Length {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
match self {
|
match self {
|
||||||
&Length::Au(length) => write!(f, "{}", length),
|
&Length::Au(length) => write!(dest, "{}px", length.to_subpx()),
|
||||||
&Length::Em(length) => write!(f, "{}em", length),
|
&Length::Em(length) => write!(dest, "{}em", length),
|
||||||
&Length::Ex(length) => write!(f, "{}ex", length),
|
&Length::Ex(length) => write!(dest, "{}ex", length),
|
||||||
&Length::Rem(length) => write!(f, "{}rem", length),
|
&Length::Rem(length) => write!(dest, "{}rem", length),
|
||||||
&Length::ServoCharacterWidth(_) => panic!("internal CSS values should never be serialized"),
|
&Length::ServoCharacterWidth(_)
|
||||||
|
=> panic!("internal CSS values should never be serialized"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const AU_PER_PX: CSSFloat = 60.;
|
const AU_PER_PX: CSSFloat = 60.;
|
||||||
const AU_PER_IN: CSSFloat = AU_PER_PX * 96.;
|
const AU_PER_IN: CSSFloat = AU_PER_PX * 96.;
|
||||||
const AU_PER_CM: CSSFloat = AU_PER_IN / 2.54;
|
const AU_PER_CM: CSSFloat = AU_PER_IN / 2.54;
|
||||||
|
@ -156,11 +223,17 @@ pub mod specified {
|
||||||
Length(Length),
|
Length(Length),
|
||||||
Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0]
|
Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0]
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for LengthOrPercentage {
|
impl fmt::Show for LengthOrPercentage {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for LengthOrPercentage {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
match self {
|
match self {
|
||||||
&LengthOrPercentage::Length(length) => write!(f, "{}", length),
|
&LengthOrPercentage::Length(length) => length.to_css(dest),
|
||||||
&LengthOrPercentage::Percentage(percentage) => write!(f, "{}%", percentage * 100.),
|
&LengthOrPercentage::Percentage(percentage)
|
||||||
|
=> write!(dest, "{}%", percentage * 100.),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,12 +268,18 @@ pub mod specified {
|
||||||
Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0]
|
Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0]
|
||||||
Auto,
|
Auto,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for LengthOrPercentageOrAuto {
|
impl fmt::Show for LengthOrPercentageOrAuto {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for LengthOrPercentageOrAuto {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
match self {
|
match self {
|
||||||
&LengthOrPercentageOrAuto::Length(length) => write!(f, "{}", length),
|
&LengthOrPercentageOrAuto::Length(length) => length.to_css(dest),
|
||||||
&LengthOrPercentageOrAuto::Percentage(percentage) => write!(f, "{}%", percentage * 100.),
|
&LengthOrPercentageOrAuto::Percentage(percentage)
|
||||||
&LengthOrPercentageOrAuto::Auto => write!(f, "auto"),
|
=> write!(dest, "{}%", percentage * 100.),
|
||||||
|
&LengthOrPercentageOrAuto::Auto => dest.write_str("auto"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,12 +314,18 @@ pub mod specified {
|
||||||
Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0]
|
Percentage(CSSFloat), // [0 .. 100%] maps to [0.0 .. 1.0]
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for LengthOrPercentageOrNone {
|
impl fmt::Show for LengthOrPercentageOrNone {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for LengthOrPercentageOrNone {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
match self {
|
match self {
|
||||||
&LengthOrPercentageOrNone::Length(length) => write!(f, "{}", length),
|
&LengthOrPercentageOrNone::Length(length) => length.to_css(dest),
|
||||||
&LengthOrPercentageOrNone::Percentage(percentage) => write!(f, "{}%", percentage * 100.),
|
&LengthOrPercentageOrNone::Percentage(percentage)
|
||||||
&LengthOrPercentageOrNone::None => write!(f, "none"),
|
=> write!(dest, "{}%", percentage * 100.),
|
||||||
|
&LengthOrPercentageOrNone::None => dest.write_str("none"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,10 +397,14 @@ pub mod specified {
|
||||||
#[deriving(Clone, PartialEq, PartialOrd)]
|
#[deriving(Clone, PartialEq, PartialOrd)]
|
||||||
pub struct Angle(pub CSSFloat);
|
pub struct Angle(pub CSSFloat);
|
||||||
|
|
||||||
impl Show for Angle {
|
impl fmt::Show for Angle {
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for Angle {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
let Angle(value) = *self;
|
let Angle(value) = *self;
|
||||||
write!(f, "{}", value)
|
write!(dest, "{}rad", value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,11 +442,20 @@ pub mod specified {
|
||||||
LinearGradient(LinearGradient),
|
LinearGradient(LinearGradient),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Show for Image {
|
impl fmt::Show for Image {
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for Image {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
match self {
|
match self {
|
||||||
&Image::Url(ref url) => write!(f, "url(\"{}\")", url),
|
&Image::Url(ref url) => {
|
||||||
&Image::LinearGradient(ref grad) => write!(f, "linear-gradient({})", grad),
|
try!(dest.write_str("url(\""));
|
||||||
|
try!(write!(CssStringWriter::new(dest), "{}", url));
|
||||||
|
try!(dest.write_str("\")"));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
&Image::LinearGradient(ref gradient) => gradient.to_css(dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,12 +503,19 @@ pub mod specified {
|
||||||
pub stops: Vec<ColorStop>,
|
pub stops: Vec<ColorStop>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Show for LinearGradient {
|
impl fmt::Show for LinearGradient {
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
let _ = write!(f, "{}", self.angle_or_corner);
|
|
||||||
for stop in self.stops.iter() {
|
|
||||||
let _ = write!(f, ", {}", stop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToCss for LinearGradient {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
|
try!(dest.write_str("linear-gradient("));
|
||||||
|
try!(self.angle_or_corner.to_css(dest));
|
||||||
|
for stop in self.stops.iter() {
|
||||||
|
try!(dest.write_str(", "));
|
||||||
|
try!(stop.to_css(dest));
|
||||||
|
}
|
||||||
|
try!(dest.write_char(')'));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,11 +527,21 @@ pub mod specified {
|
||||||
Corner(HorizontalDirection, VerticalDirection),
|
Corner(HorizontalDirection, VerticalDirection),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Show for AngleOrCorner {
|
impl fmt::Show for AngleOrCorner {
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for AngleOrCorner {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
match self {
|
match self {
|
||||||
&AngleOrCorner::Angle(angle) => write!(f, "{}", angle),
|
&AngleOrCorner::Angle(angle) => angle.to_css(dest),
|
||||||
&AngleOrCorner::Corner(horiz, vert) => write!(f, "to {} {}", horiz, vert),
|
&AngleOrCorner::Corner(horizontal, vertical) => {
|
||||||
|
try!(dest.write_str("to "));
|
||||||
|
try!(horizontal.to_css(dest));
|
||||||
|
try!(dest.write_char(' '));
|
||||||
|
try!(vertical.to_css(dest));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,45 +557,23 @@ pub mod specified {
|
||||||
pub position: Option<LengthOrPercentage>,
|
pub position: Option<LengthOrPercentage>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Show for ColorStop {
|
impl fmt::Show for ColorStop {
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> {
|
#[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.fmt_to_css(f) }
|
||||||
let _ = write!(f, "{}", self.color);
|
}
|
||||||
self.position.map(|pos| {
|
|
||||||
let _ = write!(f, " {}", pos);
|
impl ToCss for ColorStop {
|
||||||
});
|
fn to_css<W>(&self, dest: &mut W) -> text_writer::Result where W: TextWriter {
|
||||||
|
try!(self.color.to_css(dest));
|
||||||
|
if let Some(position) = self.position {
|
||||||
|
try!(dest.write_char(' '));
|
||||||
|
try!(position.to_css(dest));
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, PartialEq)]
|
define_css_keyword_enum!(HorizontalDirection: "left" => Left, "right" => Right)
|
||||||
pub enum HorizontalDirection {
|
define_css_keyword_enum!(VerticalDirection: "top" => Top, "bottom" => Bottom)
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Show for HorizontalDirection {
|
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> {
|
|
||||||
match self {
|
|
||||||
&HorizontalDirection::Left => write!(f, "left"),
|
|
||||||
&HorizontalDirection::Right => write!(f, "right"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Clone, PartialEq)]
|
|
||||||
pub enum VerticalDirection {
|
|
||||||
Top,
|
|
||||||
Bottom,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Show for VerticalDirection {
|
|
||||||
fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> {
|
|
||||||
match self {
|
|
||||||
&VerticalDirection::Top => write!(f, "top"),
|
|
||||||
&VerticalDirection::Bottom => write!(f, "bottom"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_color_stop(source: ParserIter) -> Result<ColorStop,()> {
|
fn parse_color_stop(source: ParserIter) -> Result<ColorStop,()> {
|
||||||
let color = match source.next() {
|
let color = match source.next() {
|
||||||
|
|
|
@ -159,40 +159,21 @@ pub mod longhands {
|
||||||
|
|
||||||
<%def name="single_keyword_computed(name, values, experimental=False)">
|
<%def name="single_keyword_computed(name, values, experimental=False)">
|
||||||
<%self:single_component_value name="${name}" experimental="${experimental}">
|
<%self:single_component_value name="${name}" experimental="${experimental}">
|
||||||
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
${caller.body()}
|
${caller.body()}
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
use std::fmt;
|
define_css_keyword_enum! { T:
|
||||||
#[allow(non_camel_case_types)]
|
|
||||||
#[deriving(PartialEq, Clone, FromPrimitive)]
|
|
||||||
pub enum T {
|
|
||||||
% for value in values.split():
|
% for value in values.split():
|
||||||
${to_rust_ident(value)},
|
"${value}" => ${to_rust_ident(value)},
|
||||||
% endfor
|
|
||||||
}
|
|
||||||
impl fmt::Show for T {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
match self {
|
|
||||||
% for value in values.split():
|
|
||||||
&T::${to_rust_ident(value)} => write!(f, "${value}"),
|
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
pub type SpecifiedValue = computed_value::T;
|
|
||||||
#[inline] pub fn get_initial_value() -> computed_value::T {
|
#[inline] pub fn get_initial_value() -> computed_value::T {
|
||||||
T::${to_rust_ident(values.split()[0])}
|
T::${to_rust_ident(values.split()[0])}
|
||||||
}
|
}
|
||||||
pub fn from_component_value(v: &ComponentValue, _base_url: &Url)
|
pub fn from_component_value(v: &ComponentValue, _base_url: &Url)
|
||||||
-> Result<SpecifiedValue, ()> {
|
-> Result<SpecifiedValue, ()> {
|
||||||
get_ident_lower(v).and_then(|keyword| {
|
computed_value::T::parse(v)
|
||||||
match keyword.as_slice() {
|
|
||||||
% for value in values.split():
|
|
||||||
"${value}" => Ok(T::${to_rust_ident(value)}),
|
|
||||||
% endfor
|
|
||||||
_ => Err(()),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</%self:single_component_value>
|
</%self:single_component_value>
|
||||||
</%def>
|
</%def>
|
||||||
|
@ -1550,111 +1531,13 @@ pub mod longhands {
|
||||||
pub fn from_component_value(value: &ComponentValue, _: &Url)
|
pub fn from_component_value(value: &ComponentValue, _: &Url)
|
||||||
-> Result<SpecifiedValue,()> {
|
-> Result<SpecifiedValue,()> {
|
||||||
match value {
|
match value {
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("auto") => Ok(T::AutoCursor),
|
&Ident(ref ident) => {
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("none") => {
|
if ident.eq_ignore_ascii_case("auto") {
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NoCursor))
|
Ok(T::AutoCursor)
|
||||||
|
} else {
|
||||||
|
util_cursor::Cursor::from_css_keyword(ident.as_slice())
|
||||||
|
.map(T::SpecifiedCursor)
|
||||||
}
|
}
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("default") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::DefaultCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("pointer") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::PointerCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("context-menu") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::ContextMenuCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("help") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::HelpCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("progress") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::ProgressCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("wait") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::WaitCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("cell") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::CellCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("crosshair") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::CrosshairCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("text") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::TextCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("vertical-text") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::VerticalTextCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("alias") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::AliasCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("copy") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::CopyCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("move") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::MoveCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("no-drop") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NoDropCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("not-allowed") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NotAllowedCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("grab") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::GrabCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("grabbing") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::GrabbingCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("e-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::EResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("n-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("ne-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NeResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("nw-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NwResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("s-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::SResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("se-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::SeResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("sw-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::SwResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("w-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::WResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("ew-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::EwResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("ns-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NsResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("nesw-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NeswResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("nwse-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::NwseResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("col-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::ColResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("row-resize") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::RowResizeCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("all-scroll") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::AllScrollCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("zoom-in") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::ZoomInCursor))
|
|
||||||
}
|
|
||||||
&Ident(ref value) if value.eq_ignore_ascii_case("zoom-out") => {
|
|
||||||
Ok(T::SpecifiedCursor(util_cursor::ZoomOutCursor))
|
|
||||||
}
|
}
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
|
@ -2547,13 +2430,13 @@ pub fn parse_property_declaration_list<I: Iterator<Node>>(input: I, base_url: &U
|
||||||
};
|
};
|
||||||
match PropertyDeclaration::parse(n.as_slice(), v.as_slice(), list, base_url, seen) {
|
match PropertyDeclaration::parse(n.as_slice(), v.as_slice(), list, base_url, seen) {
|
||||||
PropertyDeclarationParseResult::UnknownProperty => log_css_error(l, format!(
|
PropertyDeclarationParseResult::UnknownProperty => log_css_error(l, format!(
|
||||||
"Unsupported property: {}:{}", n, v.iter().to_css()).as_slice()),
|
"Unsupported property: {}:{}", n, v.to_css_string()).as_slice()),
|
||||||
PropertyDeclarationParseResult::ExperimentalProperty => log_css_error(l, format!(
|
PropertyDeclarationParseResult::ExperimentalProperty => log_css_error(l, format!(
|
||||||
"Experimental property, use `servo --enable_experimental` \
|
"Experimental property, use `servo --enable_experimental` \
|
||||||
or `servo -e` to enable: {}:{}",
|
or `servo -e` to enable: {}:{}",
|
||||||
n, v.iter().to_css()).as_slice()),
|
n, v.to_css_string()).as_slice()),
|
||||||
PropertyDeclarationParseResult::InvalidValue => log_css_error(l, format!(
|
PropertyDeclarationParseResult::InvalidValue => log_css_error(l, format!(
|
||||||
"Invalid value: {}:{}", n, v.iter().to_css()).as_slice()),
|
"Invalid value: {}:{}", n, v.to_css_string()).as_slice()),
|
||||||
PropertyDeclarationParseResult::ValidOrIgnoredDeclaration => (),
|
PropertyDeclarationParseResult::ValidOrIgnoredDeclaration => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ pub fn parse_style_rule(context: &ParserContext,
|
||||||
block
|
block
|
||||||
} = rule;
|
} = rule;
|
||||||
// FIXME: avoid doing this for valid selectors
|
// FIXME: avoid doing this for valid selectors
|
||||||
let serialized = prelude.iter().to_css();
|
let serialized = prelude.to_css_string();
|
||||||
match selectors::parse_selector_list(context, prelude.into_iter(), namespaces) {
|
match selectors::parse_selector_list(context, prelude.into_iter(), namespaces) {
|
||||||
Ok(selectors) => parent_rules.push(CSSRule::Style(StyleRule{
|
Ok(selectors) => parent_rules.push(CSSRule::Style(StyleRule{
|
||||||
selectors: selectors,
|
selectors: selectors,
|
||||||
|
|
|
@ -7,6 +7,9 @@ authors = ["The Servo Project Developers"]
|
||||||
name = "util"
|
name = "util"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
|
[dependencies.plugins]
|
||||||
|
path = "../plugins"
|
||||||
|
|
||||||
[dependencies.cssparser]
|
[dependencies.cssparser]
|
||||||
git = "https://github.com/servo/rust-cssparser"
|
git = "https://github.com/servo/rust-cssparser"
|
||||||
|
|
||||||
|
@ -30,3 +33,6 @@ git = "https://github.com/servo/rust-url"
|
||||||
|
|
||||||
[dependencies.time]
|
[dependencies.time]
|
||||||
git = "https://github.com/rust-lang/time"
|
git = "https://github.com/rust-lang/time"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
text_writer = "0.1.1"
|
||||||
|
|
|
@ -4,43 +4,73 @@
|
||||||
|
|
||||||
//! A list of common mouse cursors per CSS3-UI § 8.1.1.
|
//! A list of common mouse cursors per CSS3-UI § 8.1.1.
|
||||||
|
|
||||||
#[deriving(Clone, PartialEq, FromPrimitive, Show)]
|
use cssparser::ToCss;
|
||||||
|
use std::ascii::AsciiExt;
|
||||||
|
use text_writer::TextWriter;
|
||||||
|
|
||||||
|
|
||||||
|
macro_rules! define_cursor {
|
||||||
|
($( $css: expr => $variant: ident = $value: expr, )+) => {
|
||||||
|
#[deriving(Clone, PartialEq, Eq, FromPrimitive, Show)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum Cursor {
|
pub enum Cursor {
|
||||||
NoCursor = 0,
|
$( $variant = $value ),+
|
||||||
DefaultCursor = 1,
|
|
||||||
PointerCursor = 2,
|
|
||||||
ContextMenuCursor = 3,
|
|
||||||
HelpCursor = 4,
|
|
||||||
ProgressCursor = 5,
|
|
||||||
WaitCursor = 6,
|
|
||||||
CellCursor = 7,
|
|
||||||
CrosshairCursor = 8,
|
|
||||||
TextCursor = 9,
|
|
||||||
VerticalTextCursor = 10,
|
|
||||||
AliasCursor = 11,
|
|
||||||
CopyCursor = 12,
|
|
||||||
MoveCursor = 13,
|
|
||||||
NoDropCursor = 14,
|
|
||||||
NotAllowedCursor = 15,
|
|
||||||
GrabCursor = 16,
|
|
||||||
GrabbingCursor = 17,
|
|
||||||
EResizeCursor = 18,
|
|
||||||
NResizeCursor = 19,
|
|
||||||
NeResizeCursor = 20,
|
|
||||||
NwResizeCursor = 21,
|
|
||||||
SResizeCursor = 22,
|
|
||||||
SeResizeCursor = 23,
|
|
||||||
SwResizeCursor = 24,
|
|
||||||
WResizeCursor = 25,
|
|
||||||
EwResizeCursor = 26,
|
|
||||||
NsResizeCursor = 27,
|
|
||||||
NeswResizeCursor = 28,
|
|
||||||
NwseResizeCursor = 29,
|
|
||||||
ColResizeCursor = 30,
|
|
||||||
RowResizeCursor = 31,
|
|
||||||
AllScrollCursor = 32,
|
|
||||||
ZoomInCursor = 33,
|
|
||||||
ZoomOutCursor = 34,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Cursor {
|
||||||
|
pub fn from_css_keyword(keyword: &str) -> Result<Cursor, ()> {
|
||||||
|
match_ignore_ascii_case! { keyword:
|
||||||
|
$( concat!($css) => Ok(Cursor::$variant) ),+
|
||||||
|
_ => Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for Cursor {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> ::text_writer::Result where W: TextWriter {
|
||||||
|
match self {
|
||||||
|
$( &Cursor::$variant => dest.write_str($css) ),+
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
define_cursor! {
|
||||||
|
"none" => NoCursor = 0,
|
||||||
|
"default" => DefaultCursor = 1,
|
||||||
|
"pointer" => PointerCursor = 2,
|
||||||
|
"context-menu" => ContextMenuCursor = 3,
|
||||||
|
"help" => HelpCursor = 4,
|
||||||
|
"progress" => ProgressCursor = 5,
|
||||||
|
"wait" => WaitCursor = 6,
|
||||||
|
"cell" => CellCursor = 7,
|
||||||
|
"crosshair" => CrosshairCursor = 8,
|
||||||
|
"text" => TextCursor = 9,
|
||||||
|
"vertical-text" => VerticalTextCursor = 10,
|
||||||
|
"alias" => AliasCursor = 11,
|
||||||
|
"copy" => CopyCursor = 12,
|
||||||
|
"move" => MoveCursor = 13,
|
||||||
|
"no-drop" => NoDropCursor = 14,
|
||||||
|
"not-allowed" => NotAllowedCursor = 15,
|
||||||
|
"grab" => GrabCursor = 16,
|
||||||
|
"grabbing" => GrabbingCursor = 17,
|
||||||
|
"e-resize" => EResizeCursor = 18,
|
||||||
|
"n-resize" => NResizeCursor = 19,
|
||||||
|
"ne-resize" => NeResizeCursor = 20,
|
||||||
|
"nw-resize" => NwResizeCursor = 21,
|
||||||
|
"s-resize" => SResizeCursor = 22,
|
||||||
|
"se-resize" => SeResizeCursor = 23,
|
||||||
|
"sw-resize" => SwResizeCursor = 24,
|
||||||
|
"w-resize" => WResizeCursor = 25,
|
||||||
|
"ew-resize" => EwResizeCursor = 26,
|
||||||
|
"ns-resize" => NsResizeCursor = 27,
|
||||||
|
"nesw-resize" => NeswResizeCursor = 28,
|
||||||
|
"nwse-resize" => NwseResizeCursor = 29,
|
||||||
|
"col-resize" => ColResizeCursor = 30,
|
||||||
|
"row-resize" => RowResizeCursor = 31,
|
||||||
|
"all-scroll" => AllScrollCursor = 32,
|
||||||
|
"zoom-in" => ZoomInCursor = 33,
|
||||||
|
"zoom-out" => ZoomOutCursor = 34,
|
||||||
|
}
|
||||||
|
|
|
@ -26,14 +26,14 @@ extern crate sync;
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="macos")]
|
||||||
extern crate task_info;
|
extern crate task_info;
|
||||||
extern crate "time" as std_time;
|
extern crate "time" as std_time;
|
||||||
|
extern crate text_writer;
|
||||||
extern crate string_cache;
|
extern crate string_cache;
|
||||||
extern crate unicode;
|
extern crate unicode;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
||||||
#[phase(plugin)]
|
#[phase(plugin)] extern crate plugins;
|
||||||
extern crate string_cache_macros;
|
#[phase(plugin)] extern crate string_cache_macros;
|
||||||
#[phase(plugin)]
|
#[phase(plugin)] extern crate lazy_static;
|
||||||
extern crate lazy_static;
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
10
ports/cef/Cargo.lock
generated
10
ports/cef/Cargo.lock
generated
|
@ -120,9 +120,10 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cssparser"
|
name = "cssparser"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-cssparser#97d8c3b20a240881573748d4eadcda610bfb888c"
|
source = "git+https://github.com/servo/rust-cssparser#a2b0b6b00ad84dc3a4b4faf77ddd63611c8ce58a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)",
|
"encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -657,6 +658,7 @@ dependencies = [
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
@ -665,6 +667,11 @@ dependencies = [
|
||||||
name = "task_info"
|
name = "task_info"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "text_writer"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -693,6 +700,7 @@ dependencies = [
|
||||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"task_info 0.0.1",
|
"task_info 0.0.1",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.0 (git+https://github.com/rust-lang/time)",
|
"time 0.1.0 (git+https://github.com/rust-lang/time)",
|
||||||
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
||||||
]
|
]
|
||||||
|
|
10
ports/gonk/Cargo.lock
generated
10
ports/gonk/Cargo.lock
generated
|
@ -103,9 +103,10 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cssparser"
|
name = "cssparser"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/servo/rust-cssparser#97d8c3b20a240881573748d4eadcda610bfb888c"
|
source = "git+https://github.com/servo/rust-cssparser#a2b0b6b00ad84dc3a4b4faf77ddd63611c8ce58a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)",
|
"encoding 0.2.3 (git+https://github.com/lifthrasiir/rust-encoding)",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -605,6 +606,7 @@ dependencies = [
|
||||||
"plugins 0.0.1",
|
"plugins 0.0.1",
|
||||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
]
|
]
|
||||||
|
@ -613,6 +615,11 @@ dependencies = [
|
||||||
name = "task_info"
|
name = "task_info"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "text_writer"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -641,6 +648,7 @@ dependencies = [
|
||||||
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
|
||||||
"task_info 0.0.1",
|
"task_info 0.0.1",
|
||||||
|
"text_writer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"time 0.1.0 (git+https://github.com/rust-lang/time)",
|
"time 0.1.0 (git+https://github.com/rust-lang/time)",
|
||||||
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
"url 0.1.0 (git+https://github.com/servo/rust-url)",
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue