From d001fd9a0a7dd26d79562abf6e34fa6839190c55 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Thu, 8 Mar 2018 21:31:06 +1100 Subject: [PATCH] Move Parse impl of SpecifiedUrl into corresponding files. --- components/style/gecko/url.rs | 9 +++++++++ components/style/servo/url.rs | 9 +++++++++ components/style/values/specified/mod.rs | 13 ------------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index 83d4b05b033..70a6ca4878d 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -102,6 +102,15 @@ impl SpecifiedUrl { } } +impl Parse for SpecifiedUrl { + fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { + let url = input.expect_url()?; + Self::parse_from_string(url.as_ref().to_owned(), context) + } +} + +impl Eq for SpecifiedUrl {} + impl MallocSizeOf for SpecifiedUrl { fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { // XXX: measure `serialization` once bug 1397971 lands diff --git a/components/style/servo/url.rs b/components/style/servo/url.rs index 7cfca564dbf..be3c31f84ef 100644 --- a/components/style/servo/url.rs +++ b/components/style/servo/url.rs @@ -102,6 +102,13 @@ impl SpecifiedUrl { } } +impl Parse for SpecifiedUrl { + fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { + let url = input.expect_url()?; + Self::parse_from_string(url.as_ref().to_owned(), context) + } +} + impl PartialEq for SpecifiedUrl { fn eq(&self, other: &Self) -> bool { // TODO(emilio): maybe we care about equality of the specified values if @@ -110,6 +117,8 @@ impl PartialEq for SpecifiedUrl { } } +impl Eq for SpecifiedUrl {} + impl ToCss for SpecifiedUrl { fn to_css(&self, dest: &mut CssWriter) -> fmt::Result where diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 56126fa7d34..7a3d51964a3 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -116,23 +116,10 @@ pub mod ui; /// Common handling for the specified value CSS url() values. pub mod url { -use cssparser::Parser; -use parser::{Parse, ParserContext}; -use style_traits::ParseError; - #[cfg(feature = "servo")] pub use ::servo::url::*; #[cfg(feature = "gecko")] pub use ::gecko::url::*; - -impl Parse for SpecifiedUrl { - fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { - let url = input.expect_url()?; - Self::parse_from_string(url.as_ref().to_owned(), context) - } -} - -impl Eq for SpecifiedUrl {} } /// Parse a `` value, with a given clamping mode.