mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +01:00
Fix related to #14101
Add Parse trait implementation for some structures
This commit is contained in:
parent
4b9693cf81
commit
9564673b5a
14 changed files with 149 additions and 114 deletions
|
@ -67,7 +67,7 @@
|
|||
|
||||
pub mod single_value {
|
||||
use cssparser::Parser;
|
||||
use parser::{ParserContext, ParserContextExtraData};
|
||||
use parser::{Parse, ParserContext, ParserContextExtraData};
|
||||
use properties::{CSSWideKeyword, DeclaredValue, Shorthand};
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
use values::{computed, specified};
|
||||
|
@ -175,13 +175,12 @@
|
|||
#![allow(unused_imports)]
|
||||
% if not property.derived_from:
|
||||
use cssparser::Parser;
|
||||
use parser::{ParserContext, ParserContextExtraData};
|
||||
use parser::{Parse, ParserContext, ParserContextExtraData};
|
||||
use properties::{CSSWideKeyword, DeclaredValue, Shorthand};
|
||||
% endif
|
||||
use values::{Auto, Either, None_, Normal};
|
||||
use cascade_info::CascadeInfo;
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use parser::Parse;
|
||||
use properties::longhands;
|
||||
use properties::property_bit_field::PropertyBitField;
|
||||
use properties::{ComputedValues, PropertyDeclaration};
|
||||
|
|
|
@ -15,7 +15,6 @@ ${helpers.predefined_type("opacity",
|
|||
<%helpers:vector_longhand name="box-shadow" allow_empty="True" animatable="True">
|
||||
use cssparser;
|
||||
use std::fmt;
|
||||
use parser::Parse;
|
||||
use style_traits::ToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
||||
|
@ -355,7 +354,6 @@ ${helpers.predefined_type("opacity",
|
|||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
use app_units::Au;
|
||||
use parser::Parse;
|
||||
use std::ascii::AsciiExt;
|
||||
use values::specified::Length;
|
||||
|
||||
|
@ -677,7 +675,6 @@ pub struct OriginParseResult {
|
|||
}
|
||||
|
||||
pub fn parse_origin(_: &ParserContext, input: &mut Parser) -> Result<OriginParseResult,()> {
|
||||
use parser::Parse;
|
||||
use values::specified::{LengthOrPercentage, Percentage};
|
||||
let (mut horizontal, mut vertical, mut depth) = (None, None, None);
|
||||
loop {
|
||||
|
|
|
@ -496,6 +496,7 @@ ${helpers.single_keyword("font-variant-position",
|
|||
|
||||
pub mod computed_value {
|
||||
use cssparser::Parser;
|
||||
use parser::Parse;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
|
||||
|
@ -542,10 +543,10 @@ ${helpers.single_keyword("font-variant-position",
|
|||
}
|
||||
}
|
||||
|
||||
impl FeatureTagValue {
|
||||
impl Parse for FeatureTagValue {
|
||||
/// https://www.w3.org/TR/css-fonts-3/#propdef-font-feature-settings
|
||||
/// <string> [ on | off | <integer> ]
|
||||
pub fn parse(input: &mut Parser) -> Result<FeatureTagValue, ()> {
|
||||
fn parse(input: &mut Parser) -> Result<Self, ()> {
|
||||
let tag = try!(input.expect_string());
|
||||
|
||||
// allowed strings of length 4 containing chars: <U+20, U+7E>
|
||||
|
|
|
@ -27,7 +27,7 @@ use euclid::size::Size2D;
|
|||
use computed_values;
|
||||
#[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
|
||||
use logical_geometry::WritingMode;
|
||||
use parser::{ParserContext, ParserContextExtraData};
|
||||
use parser::{Parse, ParserContext, ParserContextExtraData};
|
||||
use style_traits::ToCss;
|
||||
use stylesheets::Origin;
|
||||
#[cfg(feature = "servo")] use values::Either;
|
||||
|
@ -49,7 +49,7 @@ pub mod declaration_block;
|
|||
|
||||
pub mod longhands {
|
||||
use cssparser::Parser;
|
||||
use parser::ParserContext;
|
||||
use parser::{Parse, ParserContext};
|
||||
use values::specified;
|
||||
|
||||
<%include file="/longhand/background.mako.rs" />
|
||||
|
@ -79,7 +79,7 @@ pub mod longhands {
|
|||
|
||||
pub mod shorthands {
|
||||
use cssparser::Parser;
|
||||
use parser::ParserContext;
|
||||
use parser::{Parse, ParserContext};
|
||||
use values::specified;
|
||||
|
||||
pub fn parse_four_sides<F, T>(input: &mut Parser, parse_one: F) -> Result<(T, T, T, T), ()>
|
||||
|
@ -344,8 +344,8 @@ pub enum CSSWideKeyword {
|
|||
UnsetKeyword,
|
||||
}
|
||||
|
||||
impl CSSWideKeyword {
|
||||
pub fn parse(input: &mut Parser) -> Result<CSSWideKeyword, ()> {
|
||||
impl Parse for CSSWideKeyword {
|
||||
fn parse(input: &mut Parser) -> Result<Self, ()> {
|
||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||
"initial" => Ok(CSSWideKeyword::InitialKeyword),
|
||||
"inherit" => Ok(CSSWideKeyword::InheritKeyword),
|
||||
|
@ -736,7 +736,7 @@ impl PropertyDeclaration {
|
|||
Ok(CSSWideKeyword::UnsetKeyword) | // Custom properties are alawys inherited
|
||||
Ok(CSSWideKeyword::InheritKeyword) => DeclaredValue::Inherit,
|
||||
Ok(CSSWideKeyword::InitialKeyword) => DeclaredValue::Initial,
|
||||
Err(()) => match ::custom_properties::parse(input) {
|
||||
Err(()) => match ::custom_properties::SpecifiedValue::parse(input) {
|
||||
Ok(value) => DeclaredValue::Value(value),
|
||||
Err(()) => return PropertyDeclarationParseResult::InvalidValue,
|
||||
}
|
||||
|
|
|
@ -149,6 +149,7 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
|||
for corner in ['top-left', 'top-right', 'bottom-right', 'bottom-left']
|
||||
)}">
|
||||
use values::specified::basic_shape::BorderRadius;
|
||||
use parser::Parse;
|
||||
|
||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||
let _ignored = context;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<%helpers:shorthand name="outline" sub_properties="outline-color outline-style outline-width">
|
||||
use properties::longhands::outline_width;
|
||||
use values::specified;
|
||||
use parser::Parse;
|
||||
|
||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||
let _unused = context;
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
|
||||
// https://drafts.csswg.org/css-flexbox/#flex-property
|
||||
<%helpers:shorthand name="flex" sub_properties="flex-grow flex-shrink flex-basis">
|
||||
use parser::Parse;
|
||||
use app_units::Au;
|
||||
use values::specified::{Number, Length, LengthOrPercentageOrAutoOrContent};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue