mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
parent
473934c989
commit
36ff89bd28
61 changed files with 73 additions and 437 deletions
|
@ -173,7 +173,6 @@ impl ToCss for AlignJustifyContent {
|
|||
}
|
||||
}
|
||||
|
||||
no_viewport_percentage!(AlignJustifyContent);
|
||||
|
||||
impl Parse for AlignJustifyContent {
|
||||
// normal | <baseline-position> |
|
||||
|
@ -223,7 +222,6 @@ impl AlignJustifySelf {
|
|||
}
|
||||
}
|
||||
|
||||
no_viewport_percentage!(AlignJustifySelf);
|
||||
|
||||
impl Parse for AlignJustifySelf {
|
||||
// auto | normal | stretch | <baseline-position> |
|
||||
|
@ -261,7 +259,6 @@ impl AlignItems {
|
|||
}
|
||||
}
|
||||
|
||||
no_viewport_percentage!(AlignItems);
|
||||
|
||||
impl Parse for AlignItems {
|
||||
// normal | stretch | <baseline-position> |
|
||||
|
@ -305,7 +302,6 @@ impl JustifyItems {
|
|||
}
|
||||
}
|
||||
|
||||
no_viewport_percentage!(JustifyItems);
|
||||
|
||||
impl Parse for JustifyItems {
|
||||
// auto | normal | stretch | <baseline-position> |
|
||||
|
|
|
@ -20,7 +20,7 @@ use values::specified::calc::CalcNode;
|
|||
/// value serialization. Therefore we are storing a computed angle inside
|
||||
/// to hold the actual value and its unit.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Angle {
|
||||
value: ComputedAngle,
|
||||
was_calc: bool,
|
||||
|
|
|
@ -18,7 +18,7 @@ use values::specified::length::{Length, LengthOrPercentage};
|
|||
|
||||
/// A specified value for a single side of the `border-width` property.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum BorderSideWidth {
|
||||
/// `thin`
|
||||
Thin,
|
||||
|
|
|
@ -11,7 +11,7 @@ use cssparser::{Parser, Token, BasicParseError};
|
|||
use parser::ParserContext;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::{HasViewportPercentage, ToCss, ParseError, StyleParseError};
|
||||
use style_traits::{ToCss, ParseError, StyleParseError};
|
||||
use style_traits::values::specified::AllowedLengthType;
|
||||
use values::{CSSInteger, CSSFloat};
|
||||
use values::computed;
|
||||
|
@ -82,13 +82,6 @@ pub struct CalcLengthOrPercentage {
|
|||
pub mozmm: Option<CSSFloat>,
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for CalcLengthOrPercentage {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
self.vw.is_some() || self.vh.is_some() ||
|
||||
self.vmin.is_some() || self.vmax.is_some()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for CalcLengthOrPercentage {
|
||||
/// https://drafts.csswg.org/css-values/#calc-serialize
|
||||
///
|
||||
|
|
|
@ -44,7 +44,6 @@ pub enum Color {
|
|||
InheritFromBodyQuirk,
|
||||
}
|
||||
|
||||
no_viewport_percentage!(Color);
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
mod gecko {
|
||||
|
@ -305,7 +304,6 @@ impl ToComputedValue for Color {
|
|||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct RGBAColor(pub Color);
|
||||
|
||||
no_viewport_percentage!(RGBAColor);
|
||||
|
||||
impl Parse for RGBAColor {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
|
|
|
@ -35,7 +35,7 @@ pub type Filter = GenericFilter<Angle, Factor, NonNegativeLength, SimpleShadow>;
|
|||
pub type Filter = GenericFilter<Angle, Factor, NonNegativeLength, Impossible>;
|
||||
|
||||
/// A value for the `<factor>` parts in `Filter`.
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct Factor(NumberOrPercentage);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use cssparser::{Parser, Token, BasicParseError};
|
|||
use parser::{Parse, ParserContext};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::mem;
|
||||
use style_traits::{HasViewportPercentage, ParseError, StyleParseError};
|
||||
use style_traits::{ParseError, StyleParseError};
|
||||
use values::{CSSFloat, CustomIdent};
|
||||
use values::generics::grid::{GridTemplateComponent, RepeatCount, TrackBreadth, TrackKeyword, TrackRepeat};
|
||||
use values::generics::grid::{LineNameList, TrackSize, TrackList, TrackListType};
|
||||
|
@ -38,17 +38,6 @@ impl Parse for TrackBreadth<LengthOrPercentage> {
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for TrackBreadth<LengthOrPercentage> {
|
||||
#[inline]
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
if let TrackBreadth::Breadth(ref lop) = *self {
|
||||
lop.has_viewport_percentage()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for TrackSize<LengthOrPercentage> {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(b) = input.try(|i| TrackBreadth::parse(context, i)) {
|
||||
|
@ -175,13 +164,6 @@ impl TrackRepeat<LengthOrPercentage> {
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for TrackRepeat<LengthOrPercentage> {
|
||||
#[inline]
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
self.track_sizes.iter().any(|ref v| v.has_viewport_percentage())
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for TrackList<LengthOrPercentage> {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
// Merge the line names while parsing values. The resulting values will
|
||||
|
@ -278,13 +260,6 @@ impl Parse for TrackList<LengthOrPercentage> {
|
|||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for TrackList<LengthOrPercentage> {
|
||||
#[inline]
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
self.values.iter().any(|ref v| v.has_viewport_percentage())
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for GridTemplateComponent<LengthOrPercentage> {
|
||||
// FIXME: Derive Parse (probably with None_)
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
|
@ -307,13 +282,3 @@ impl GridTemplateComponent<LengthOrPercentage> {
|
|||
LineNameList::parse(context, input).map(GridTemplateComponent::Subgrid)
|
||||
}
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for GridTemplateComponent<LengthOrPercentage> {
|
||||
#[inline]
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
GridTemplateComponent::TrackList(ref l) => l.has_viewport_percentage(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ pub type GradientKind = GenericGradientKind<
|
|||
>;
|
||||
|
||||
/// A specified gradient line direction.
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum LineDirection {
|
||||
/// An angular direction.
|
||||
|
@ -105,7 +105,7 @@ pub enum LineDirection {
|
|||
}
|
||||
|
||||
/// A binary enum to hold either Position or LegacyPosition.
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
#[cfg(feature = "gecko")]
|
||||
pub enum GradientPosition {
|
||||
/// 1, 2, 3, 4-valued <position>.
|
||||
|
|
|
@ -14,7 +14,7 @@ use parser::{Parse, ParserContext};
|
|||
use std::{cmp, fmt, mem};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::ops::Mul;
|
||||
use style_traits::{HasViewportPercentage, ToCss, ParseError, StyleParseError};
|
||||
use style_traits::{ToCss, ParseError, StyleParseError};
|
||||
use style_traits::values::specified::AllowedLengthType;
|
||||
use stylesheets::CssRuleType;
|
||||
use super::{AllowQuirks, Number, ToComputedValue, Percentage};
|
||||
|
@ -183,12 +183,6 @@ pub enum ViewportPercentageLength {
|
|||
Vmax(CSSFloat)
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for ViewportPercentageLength {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for ViewportPercentageLength {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
|
@ -422,15 +416,6 @@ pub enum NoCalcLength {
|
|||
Physical(PhysicalLength),
|
||||
}
|
||||
|
||||
impl HasViewportPercentage for NoCalcLength {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
NoCalcLength::ViewportPercentage(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for NoCalcLength {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
|
@ -545,7 +530,7 @@ impl NoCalcLength {
|
|||
///
|
||||
/// https://drafts.csswg.org/css-values/#lengths
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum Length {
|
||||
/// The internal length type that cannot parse `calc`
|
||||
NoCalc(NoCalcLength),
|
||||
|
@ -759,7 +744,7 @@ pub type NonNegativeLengthOrNumber = Either<NonNegativeLength, NonNegativeNumber
|
|||
/// A length or a percentage value.
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum LengthOrPercentage {
|
||||
Length(NoCalcLength),
|
||||
Percentage(computed::Percentage),
|
||||
|
@ -929,7 +914,7 @@ impl LengthOrPercentage {
|
|||
/// Either a `<length>`, a `<percentage>`, or the `auto` keyword.
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum LengthOrPercentageOrAuto {
|
||||
Length(NoCalcLength),
|
||||
Percentage(computed::Percentage),
|
||||
|
@ -1045,7 +1030,7 @@ impl LengthOrPercentageOrAuto {
|
|||
|
||||
/// Either a `<length>`, a `<percentage>`, or the `none` keyword.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum LengthOrPercentageOrNone {
|
||||
Length(NoCalcLength),
|
||||
|
@ -1193,7 +1178,7 @@ impl LengthOrNumber {
|
|||
/// `auto`, and cannot be `none`.
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum MozLength {
|
||||
LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
|
||||
ExtremumLength(ExtremumLength),
|
||||
|
@ -1219,7 +1204,7 @@ impl MozLength {
|
|||
/// A value suitable for a `max-width` or `max-height` property.
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum MaxLength {
|
||||
LengthOrPercentageOrNone(LengthOrPercentageOrNone),
|
||||
ExtremumLength(ExtremumLength),
|
||||
|
|
|
@ -102,7 +102,6 @@ impl Eq for SpecifiedUrl {}
|
|||
#[cfg(feature = "gecko")]
|
||||
impl ComputedValueAsSpecified for SpecifiedUrl {}
|
||||
|
||||
no_viewport_percentage!(SpecifiedUrl);
|
||||
}
|
||||
|
||||
/// Parse an `<integer>` value, handling `calc()` correctly.
|
||||
|
@ -171,7 +170,6 @@ define_numbered_css_keyword_enum! { BorderStyle:
|
|||
"outset" => outset = 2,
|
||||
}
|
||||
|
||||
no_viewport_percentage!(BorderStyle);
|
||||
|
||||
impl BorderStyle {
|
||||
/// Whether this border style is either none or hidden.
|
||||
|
@ -191,7 +189,6 @@ pub struct Number {
|
|||
calc_clamping_mode: Option<AllowedNumericType>,
|
||||
}
|
||||
|
||||
no_viewport_percentage!(Number);
|
||||
|
||||
impl Parse for Number {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
|
@ -296,7 +293,6 @@ pub enum NumberOrPercentage {
|
|||
Number(Number),
|
||||
}
|
||||
|
||||
no_viewport_percentage!(NumberOrPercentage);
|
||||
|
||||
impl NumberOrPercentage {
|
||||
fn parse_with_clamping_mode<'i, 't>(
|
||||
|
@ -329,7 +325,6 @@ impl Parse for NumberOrPercentage {
|
|||
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, ToCss)]
|
||||
pub struct Opacity(Number);
|
||||
|
||||
no_viewport_percentage!(Opacity);
|
||||
|
||||
impl Parse for Opacity {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
|
@ -389,7 +384,6 @@ impl Integer {
|
|||
}
|
||||
}
|
||||
|
||||
no_viewport_percentage!(Integer);
|
||||
|
||||
impl Parse for Integer {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
|
@ -498,7 +492,7 @@ pub type LengthOrPercentageOrNumber = Either<Number, LengthOrPercentage>;
|
|||
/// NonNegativeLengthOrPercentage | NonNegativeNumber
|
||||
pub type NonNegativeLengthOrPercentageOrNumber = Either<NonNegativeNumber, NonNegativeLengthOrPercentage>;
|
||||
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
/// rect(<top>, <left>, <bottom>, <right>) used by clip and image-region
|
||||
pub struct ClipRect {
|
||||
|
|
|
@ -28,7 +28,6 @@ pub struct Percentage {
|
|||
calc_clamping_mode: Option<AllowedNumericType>,
|
||||
}
|
||||
|
||||
no_viewport_percentage!(Percentage);
|
||||
|
||||
impl ToCss for Percentage {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use std::fmt;
|
||||
use style_traits::{HasViewportPercentage, ToCss, ParseError};
|
||||
use style_traits::{ToCss, ParseError};
|
||||
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage as ComputedLengthOrPercentage};
|
||||
use values::computed::{Context, Percentage, ToComputedValue};
|
||||
use values::generics::position::Position as GenericPosition;
|
||||
|
@ -156,18 +156,6 @@ impl ToCss for Position {
|
|||
}
|
||||
}
|
||||
|
||||
impl<S> HasViewportPercentage for PositionComponent<S> {
|
||||
fn has_viewport_percentage(&self) -> bool {
|
||||
match *self {
|
||||
PositionComponent::Length(ref lop) |
|
||||
PositionComponent::Side(_, Some(ref lop)) => {
|
||||
lop.has_viewport_percentage()
|
||||
},
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Parse> Parse for PositionComponent<S> {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
Self::parse_quirky(context, input, AllowQuirks::No)
|
||||
|
|
|
@ -15,7 +15,6 @@ use values::specified::color::RGBAColor;
|
|||
/// Specified SVG Paint value
|
||||
pub type SVGPaint = generic::SVGPaint<RGBAColor, SpecifiedUrl>;
|
||||
|
||||
no_viewport_percentage!(SVGPaint);
|
||||
|
||||
/// Specified SVG Paint Kind value
|
||||
pub type SVGPaintKind = generic::SVGPaintKind<RGBAColor, SpecifiedUrl>;
|
||||
|
|
|
@ -16,7 +16,7 @@ use values::computed::time::Time as ComputedTime;
|
|||
use values::specified::calc::CalcNode;
|
||||
|
||||
/// A time value according to CSS-VALUES § 6.2.
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct Time {
|
||||
seconds: CSSFloat,
|
||||
|
@ -25,7 +25,7 @@ pub struct Time {
|
|||
}
|
||||
|
||||
/// A time unit.
|
||||
#[derive(Clone, Copy, Debug, Eq, HasViewportPercentage, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum TimeUnit {
|
||||
/// `s`
|
||||
|
|
|
@ -22,7 +22,7 @@ pub type TransformOrigin = GenericTransformOrigin<OriginComponent<X>, OriginComp
|
|||
|
||||
/// The specified value of a component of a CSS `<transform-origin>`.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum OriginComponent<S> {
|
||||
/// `center`
|
||||
Center,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue