mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Support shape-image: <image>
MozReview-Commit-ID: GSCZIMEpCS2
This commit is contained in:
parent
b8b5c5371f
commit
f3dbaad222
5 changed files with 82 additions and 27 deletions
|
@ -22,6 +22,7 @@ use values::generics::basic_shape::{Polygon as GenericPolygon, ShapeRadius as Ge
|
|||
use values::generics::rect::Rect;
|
||||
use values::specified::LengthOrPercentage;
|
||||
use values::specified::border::BorderRadius;
|
||||
use values::specified::image::Image;
|
||||
use values::specified::position::{HorizontalPosition, Position, PositionComponent, Side, VerticalPosition};
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
|
@ -29,7 +30,7 @@ use values::specified::url::SpecifiedUrl;
|
|||
pub type ClippingShape = GenericClippingShape<BasicShape, SpecifiedUrl>;
|
||||
|
||||
/// A specified float area shape.
|
||||
pub type FloatAreaShape = GenericFloatAreaShape<BasicShape, SpecifiedUrl>;
|
||||
pub type FloatAreaShape = GenericFloatAreaShape<BasicShape, Image>;
|
||||
|
||||
/// A specified basic shape.
|
||||
pub type BasicShape = GenericBasicShape<HorizontalPosition, VerticalPosition, LengthOrPercentage>;
|
||||
|
@ -49,14 +50,18 @@ pub type ShapeRadius = GenericShapeRadius<LengthOrPercentage>;
|
|||
/// The specified value of `Polygon`
|
||||
pub type Polygon = GenericPolygon<LengthOrPercentage>;
|
||||
|
||||
impl<ReferenceBox: Parse> Parse for ShapeSource<BasicShape, ReferenceBox, SpecifiedUrl> {
|
||||
impl<ReferenceBox, ImageOrUrl> Parse for ShapeSource<BasicShape, ReferenceBox, ImageOrUrl>
|
||||
where
|
||||
ReferenceBox: Parse,
|
||||
ImageOrUrl: Parse,
|
||||
{
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(ShapeSource::None)
|
||||
}
|
||||
|
||||
if let Ok(url) = input.try(|i| SpecifiedUrl::parse(context, i)) {
|
||||
return Ok(ShapeSource::Url(url))
|
||||
if let Ok(image_or_url) = input.try(|i| ImageOrUrl::parse(context, i)) {
|
||||
return Ok(ShapeSource::ImageOrUrl(image_or_url))
|
||||
}
|
||||
|
||||
fn parse_component<U: Parse>(context: &ParserContext, input: &mut Parser,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue