mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Use generics for initial-letter
The former version used ComputedValueAsSpecified, which means we were storing specified numbers and integers in the computed value.
This commit is contained in:
parent
f388c0ab1e
commit
7d09ce0495
7 changed files with 83 additions and 82 deletions
|
@ -9,10 +9,15 @@ use parser::{Parse, ParserContext};
|
|||
use std::ascii::AsciiExt;
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
use values::computed::text::LineHeight as ComputedLineHeight;
|
||||
use values::generics::text::{LineHeight as GenericLineHeight, Spacing};
|
||||
use values::specified::{AllowQuirks, Number};
|
||||
use values::generics::text::InitialLetter as GenericInitialLetter;
|
||||
use values::generics::text::LineHeight as GenericLineHeight;
|
||||
use values::generics::text::Spacing;
|
||||
use values::specified::{AllowQuirks, Integer, Number};
|
||||
use values::specified::length::{FontRelativeLength, Length, LengthOrPercentage, NoCalcLength};
|
||||
|
||||
/// A specified type for the `initial-letter` property.
|
||||
pub type InitialLetter = GenericInitialLetter<Number, Integer>;
|
||||
|
||||
/// A specified value for the `letter-spacing` property.
|
||||
pub type LetterSpacing = Spacing<Length>;
|
||||
|
||||
|
@ -22,6 +27,17 @@ pub type WordSpacing = Spacing<LengthOrPercentage>;
|
|||
/// A specified value for the `line-height` property.
|
||||
pub type LineHeight = GenericLineHeight<Number, LengthOrPercentage>;
|
||||
|
||||
impl Parse for InitialLetter {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
if input.try(|i| i.expect_ident_matching("normal")).is_ok() {
|
||||
return Ok(GenericInitialLetter::Normal);
|
||||
}
|
||||
let size = Number::parse_at_least_one(context, input)?;
|
||||
let sink = input.try(|i| Integer::parse_positive(context, i)).ok();
|
||||
Ok(GenericInitialLetter::Specified(size, sink))
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for LetterSpacing {
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
Spacing::parse_with(context, input, |c, i| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue