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
|
@ -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