Auto merge of #12878 - Manishearth:clip-path, r=heycam

stylo: Support clip-path

Todo:

 - [x] `set_clip_path` (probably needs a bunch of gecko bindings for running constructors/destructors)
 - [ ] Ensure that I've ordered the coordinates correctly
 - [ ] Check that it works
 - [x] Might want to convert NS_STYLE_FILL_RULE and NS_RADIUS to enum classes

Depends on:

 - https://github.com/servo/rust-bindgen/pull/29
 - https://github.com/Manishearth/gecko-dev/compare/servo:stylo...Manishearth:clip-path

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12878)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-19 14:24:08 -05:00 committed by GitHub
commit 609d47b44f
14 changed files with 627 additions and 14 deletions

View file

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