mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #20482 - brainlessdeveloper:list-style-image-computed, r=emilio
Implement a URL-generic type for ListStyleImage <!-- Please describe your changes on the following line: --> This should fix the following two "expected to fail" tests described in https://github.com/servo/servo/issues/18015: - getComputedStyle(elem) for url() listStyleImage uses the resolved URL and elem.style uses the original URL - getComputedStyle(elem) for url() listStyle uses the resolved URL and elem.style uses the original URL I updated the test failure expectations by removing the corresponding `.ini` file. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #18015 (github issue number if applicable). <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20482) <!-- Reviewable:end -->
This commit is contained in:
commit
d744e35d38
26 changed files with 157 additions and 124 deletions
|
@ -13,10 +13,10 @@ use euclid::{Point2D, Size2D};
|
|||
use smallvec::SmallVec;
|
||||
use values::computed::Angle as ComputedAngle;
|
||||
use values::computed::BorderCornerRadius as ComputedBorderCornerRadius;
|
||||
#[cfg(feature = "servo")]
|
||||
use values::computed::ComputedUrl;
|
||||
use values::computed::MaxLength as ComputedMaxLength;
|
||||
use values::computed::MozLength as ComputedMozLength;
|
||||
#[cfg(feature = "servo")]
|
||||
use values::computed::url::ComputedUrl;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
pub mod color;
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
use values::computed::{LengthOrPercentage, ComputedUrl, Image};
|
||||
use values::computed::{LengthOrPercentage, Image};
|
||||
use values::computed::url::ComputedUrl;
|
||||
use values::generics::basic_shape::{BasicShape as GenericBasicShape};
|
||||
use values::generics::basic_shape::{Circle as GenericCircle, ClippingShape as GenericClippingShape};
|
||||
use values::generics::basic_shape::{Ellipse as GenericEllipse, FloatAreaShape as GenericFloatAreaShape};
|
||||
|
|
|
@ -12,11 +12,12 @@ use std::f32::consts::PI;
|
|||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
use values::{Either, None_};
|
||||
use values::computed::{Angle, ComputedImageUrl, Context};
|
||||
use values::computed::{Angle, Context};
|
||||
use values::computed::{Length, LengthOrPercentage, NumberOrPercentage, ToComputedValue};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::computed::Percentage;
|
||||
use values::computed::position::Position;
|
||||
use values::computed::url::ComputedImageUrl;
|
||||
use values::generics::image::{CompatMode, ColorStop as GenericColorStop, EndingShape as GenericEndingShape};
|
||||
use values::generics::image::{Gradient as GenericGradient, GradientItem as GenericGradientItem};
|
||||
use values::generics::image::{Image as GenericImage, GradientKind as GenericGradientKind};
|
||||
|
|
|
@ -21,7 +21,8 @@ use values::specified::length::{AbsoluteLength, FontBaseSize, FontRelativeLength
|
|||
use values::specified::length::ViewportPercentageLength;
|
||||
|
||||
pub use super::image::Image;
|
||||
pub use values::specified::{Angle, BorderStyle, Time, UrlOrNone};
|
||||
pub use values::specified::url::UrlOrNone;
|
||||
pub use values::specified::{Angle, BorderStyle, Time};
|
||||
|
||||
impl ToComputedValue for specified::NoCalcLength {
|
||||
type ComputedValue = CSSPixelLength;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! `list` computed values.
|
||||
|
||||
pub use values::specified::list::{ListStyleImage, Quotes};
|
||||
pub use values::specified::list::Quotes;
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use values::specified::list::ListStyleType;
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNumber, LengthOrP
|
|||
pub use self::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::{CSSPixelLength, ExtremumLength, NonNegativeLength};
|
||||
pub use self::length::{NonNegativeLengthOrPercentage, NonNegativeLengthOrPercentageOrAuto};
|
||||
pub use self::list::{ListStyleImage, Quotes};
|
||||
pub use self::list::Quotes;
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use self::list::ListStyleType;
|
||||
pub use self::outline::OutlineStyle;
|
||||
|
@ -81,7 +81,6 @@ pub use self::time::Time;
|
|||
pub use self::transform::{Rotate, Scale, TimingFunction, Transform, TransformOperation};
|
||||
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
||||
pub use self::ui::MozForceBrokenImageIcon;
|
||||
pub use self::url::{ComputedUrl, ComputedImageUrl};
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub mod align;
|
||||
|
@ -114,14 +113,7 @@ pub mod text;
|
|||
pub mod time;
|
||||
pub mod transform;
|
||||
pub mod ui;
|
||||
|
||||
/// Common handling for the computed value CSS url() values.
|
||||
pub mod url {
|
||||
#[cfg(feature = "servo")]
|
||||
pub use ::servo::url::{ComputedUrl, ComputedImageUrl};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use ::gecko::url::{ComputedUrl, ComputedImageUrl};
|
||||
}
|
||||
pub mod url;
|
||||
|
||||
/// A `Context` is all the data a specified value could ever need to compute
|
||||
/// itself and be transformed to a computed value.
|
||||
|
@ -639,9 +631,3 @@ impl ClipRectOrAuto {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <url> | <none>
|
||||
pub type UrlOrNone = Either<ComputedUrl, None_>;
|
||||
|
||||
/// <url> | <none> for image
|
||||
pub type ImageUrlOrNone = Either<ComputedImageUrl, None_>;
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
use app_units::Au;
|
||||
use values::RGBA;
|
||||
use values::computed::{ComputedUrl, LengthOrPercentage, NonNegativeLength};
|
||||
use values::computed::{LengthOrPercentage, NonNegativeLength};
|
||||
use values::computed::{NonNegativeNumber, NonNegativeLengthOrPercentage, Number};
|
||||
use values::computed::Opacity;
|
||||
use values::computed::url::ComputedUrl;
|
||||
use values::generics::svg as generic;
|
||||
|
||||
pub use values::specified::SVGPaintOrder;
|
||||
|
|
18
components/style/values/computed/url.rs
Normal file
18
components/style/values/computed/url.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Common handling for the computed value CSS url() values.
|
||||
|
||||
use values::generics::url::UrlOrNone as GenericUrlOrNone;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub use ::servo::url::{ComputedUrl, ComputedImageUrl};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use ::gecko::url::{ComputedUrl, ComputedImageUrl};
|
||||
|
||||
/// Computed <url> | <none>
|
||||
pub type UrlOrNone = GenericUrlOrNone<ComputedUrl>;
|
||||
|
||||
/// Computed image <url> | <none>
|
||||
pub type ImageUrlOrNone = GenericUrlOrNone<ComputedImageUrl>;
|
|
@ -32,6 +32,7 @@ pub mod size;
|
|||
pub mod svg;
|
||||
pub mod text;
|
||||
pub mod transform;
|
||||
pub mod url;
|
||||
|
||||
// https://drafts.csswg.org/css-counter-styles/#typedef-symbols-type
|
||||
#[allow(missing_docs)]
|
||||
|
|
39
components/style/values/generics/url.rs
Normal file
39
components/style/values/generics/url.rs
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Generic types for url properties.
|
||||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use style_traits::ParseError;
|
||||
|
||||
/// An image url or none, used for example in list-style-image
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
pub enum UrlOrNone<Url> {
|
||||
/// `none`
|
||||
None,
|
||||
/// `A URL`
|
||||
Url(Url),
|
||||
}
|
||||
|
||||
impl<Url> UrlOrNone<Url> {
|
||||
/// Initial "none" value for properties such as `list-style-image`
|
||||
pub fn none() -> Self {
|
||||
UrlOrNone::None
|
||||
}
|
||||
}
|
||||
|
||||
impl<Url> Parse for UrlOrNone<Url> where Url: Parse {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<UrlOrNone<Url>, ParseError<'i>> {
|
||||
if let Ok(url) = input.try(|input| Url::parse(context, input)) {
|
||||
return Ok(UrlOrNone::Url(url));
|
||||
}
|
||||
input.expect_ident_matching("none")?;
|
||||
Ok(UrlOrNone::None)
|
||||
}
|
||||
}
|
|
@ -8,12 +8,10 @@ use cssparser::{Parser, Token};
|
|||
use parser::{Parse, ParserContext};
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use values::{Either, None_};
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::CustomIdent;
|
||||
#[cfg(feature = "gecko")]
|
||||
use values::generics::CounterStyleOrNone;
|
||||
use values::specified::ImageUrlOrNone;
|
||||
|
||||
/// Specified and computed `list-style-type` property.
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -73,31 +71,6 @@ impl Parse for ListStyleType {
|
|||
}
|
||||
}
|
||||
|
||||
/// Specified and computed `list-style-image` property.
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||
pub struct ListStyleImage(pub ImageUrlOrNone);
|
||||
|
||||
// FIXME(nox): This is wrong, there are different types for specified
|
||||
// and computed URLs in Servo.
|
||||
trivial_to_computed_value!(ListStyleImage);
|
||||
|
||||
impl ListStyleImage {
|
||||
/// Initial specified value for `list-style-image`.
|
||||
#[inline]
|
||||
pub fn none() -> ListStyleImage {
|
||||
ListStyleImage(Either::Second(None_))
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for ListStyleImage {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<ListStyleImage, ParseError<'i>> {
|
||||
ImageUrlOrNone::parse(context, input).map(ListStyleImage)
|
||||
}
|
||||
}
|
||||
|
||||
/// Specified and computed `quote` property.
|
||||
///
|
||||
/// FIXME(emilio): It's a shame that this allocates all the time it's computed,
|
||||
|
|
|
@ -11,12 +11,11 @@ use context::QuirksMode;
|
|||
use cssparser::{Parser, Token, serialize_identifier};
|
||||
use num_traits::One;
|
||||
use parser::{ParserContext, Parse};
|
||||
use self::url::{SpecifiedImageUrl, SpecifiedUrl};
|
||||
use std::f32;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
use super::{Auto, CSSFloat, CSSInteger, Either, None_};
|
||||
use super::{Auto, CSSFloat, CSSInteger, Either};
|
||||
use super::computed::{Context, ToComputedValue};
|
||||
use super::generics::{GreaterThanOrEqualToOne, NonNegative};
|
||||
use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as GenericTrackBreadth};
|
||||
|
@ -56,7 +55,7 @@ pub use self::length::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
|||
pub use self::length::{LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::{NoCalcLength, ViewportPercentageLength};
|
||||
pub use self::length::{NonNegativeLengthOrPercentage, NonNegativeLengthOrPercentageOrAuto};
|
||||
pub use self::list::{ListStyleImage, Quotes};
|
||||
pub use self::list::Quotes;
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use self::list::ListStyleType;
|
||||
pub use self::outline::OutlineStyle;
|
||||
|
@ -114,14 +113,7 @@ pub mod text;
|
|||
pub mod time;
|
||||
pub mod transform;
|
||||
pub mod ui;
|
||||
|
||||
/// Common handling for the specified value CSS url() values.
|
||||
pub mod url {
|
||||
#[cfg(feature = "servo")]
|
||||
pub use ::servo::url::{SpecifiedUrl, SpecifiedImageUrl};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use ::gecko::url::{SpecifiedUrl, SpecifiedImageUrl};
|
||||
}
|
||||
pub mod url;
|
||||
|
||||
/// Parse a `<number>` value, with a given clamping mode.
|
||||
fn parse_number_with_clamping_mode<'i, 't>(
|
||||
|
@ -519,12 +511,6 @@ impl Parse for PositiveInteger {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(missing_docs)]
|
||||
pub type UrlOrNone = Either<SpecifiedUrl, None_>;
|
||||
|
||||
/// The specified value of a `<url>` for image or `none`.
|
||||
pub type ImageUrlOrNone = Either<SpecifiedImageUrl, None_>;
|
||||
|
||||
/// The specified value of a grid `<track-breadth>`
|
||||
pub type TrackBreadth = GenericTrackBreadth<LengthOrPercentage>;
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@ use style_traits::{StyleParseErrorKind, ToCss};
|
|||
use values::CustomIdent;
|
||||
use values::generics::svg as generic;
|
||||
use values::specified::{LengthOrPercentage, NonNegativeLengthOrPercentage, NonNegativeNumber};
|
||||
use values::specified::{Number, Opacity, SpecifiedUrl};
|
||||
use values::specified::{Number, Opacity};
|
||||
use values::specified::color::RGBAColor;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
/// Specified SVG Paint value
|
||||
pub type SVGPaint = generic::SVGPaint<RGBAColor, SpecifiedUrl>;
|
||||
|
|
18
components/style/values/specified/url.rs
Normal file
18
components/style/values/specified/url.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Common handling for the specified value CSS url() values.
|
||||
|
||||
use values::generics::url::UrlOrNone as GenericUrlOrNone;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub use ::servo::url::{SpecifiedUrl, SpecifiedImageUrl};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use ::gecko::url::{SpecifiedUrl, SpecifiedImageUrl};
|
||||
|
||||
/// Specified <url> | <none>
|
||||
pub type UrlOrNone = GenericUrlOrNone<SpecifiedUrl>;
|
||||
|
||||
/// Specified image <url> | <none>
|
||||
pub type ImageUrlOrNone = GenericUrlOrNone<SpecifiedImageUrl>;
|
Loading…
Add table
Add a link
Reference in a new issue