mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Implement -webkit-gradient() (fixes #16542)
This commit is contained in:
parent
9e6f9db127
commit
ea4e7299d4
4 changed files with 285 additions and 16 deletions
|
@ -15,7 +15,7 @@ use std::{cmp, fmt, mem};
|
|||
use std::ascii::AsciiExt;
|
||||
use std::ops::Mul;
|
||||
use style_traits::ToCss;
|
||||
use style_traits::values::specified::AllowedLengthType;
|
||||
use style_traits::values::specified::{AllowedLengthType, AllowedNumericType};
|
||||
use stylesheets::CssRuleType;
|
||||
use super::{AllowQuirks, Number, ToComputedValue};
|
||||
use values::{Auto, CSSFloat, Either, FONT_MEDIUM_PX, HasViewportPercentage, None_, Normal};
|
||||
|
@ -729,7 +729,10 @@ impl ToCss for Percentage {
|
|||
}
|
||||
|
||||
impl Percentage {
|
||||
fn parse_internal(input: &mut Parser, context: AllowedLengthType) -> Result<Self, ()> {
|
||||
/// Parse a specific kind of percentage.
|
||||
pub fn parse_with_clamping_mode(input: &mut Parser,
|
||||
context: AllowedNumericType)
|
||||
-> Result<Self, ()> {
|
||||
match try!(input.next()) {
|
||||
Token::Percentage(ref value) if context.is_ok(value.unit_value) => {
|
||||
Ok(Percentage(value.unit_value))
|
||||
|
@ -740,14 +743,14 @@ impl Percentage {
|
|||
|
||||
/// Parses a percentage token, but rejects it if it's negative.
|
||||
pub fn parse_non_negative(input: &mut Parser) -> Result<Self, ()> {
|
||||
Self::parse_internal(input, AllowedLengthType::NonNegative)
|
||||
Self::parse_with_clamping_mode(input, AllowedNumericType::NonNegative)
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for Percentage {
|
||||
#[inline]
|
||||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
Self::parse_internal(input, AllowedLengthType::All)
|
||||
Self::parse_with_clamping_mode(input, AllowedNumericType::All)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue