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:
bors-servo 2018-04-03 18:12:13 -04:00 committed by GitHub
commit d744e35d38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 157 additions and 124 deletions

View file

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

View 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)
}
}