style: Centralize specified url value handling, and refcount urls.

This commit is contained in:
Emilio Cobos Álvarez 2016-10-16 15:08:30 +02:00
parent 89c46369a2
commit 5f2e7af864
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
22 changed files with 267 additions and 187 deletions

View file

@ -10,17 +10,16 @@
use properties::shorthands::serialize_four_sides;
use std::fmt;
use style_traits::ToCss;
use url::Url;
use values::computed::{BorderRadiusSize, LengthOrPercentage};
use values::computed::UrlExtraData;
use values::computed::position::Position;
use values::specified::url::SpecifiedUrl;
pub use values::specified::basic_shape::{FillRule, GeometryBox, ShapeBox};
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum ShapeSource<T> {
Url(Url, UrlExtraData),
Url(SpecifiedUrl),
Shape(BasicShape, Option<T>),
Box(T),
None,
@ -35,7 +34,7 @@ impl<T> Default for ShapeSource<T> {
impl<T: ToCss> ToCss for ShapeSource<T> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
ShapeSource::Url(ref url, _) => url.to_css(dest),
ShapeSource::Url(ref url) => url.to_css(dest),
ShapeSource::Shape(ref shape, Some(ref reference)) => {
try!(shape.to_css(dest));
try!(dest.write_str(" "));