servo: Merge #20482 - Implement a URL-generic type for ListStyleImage (from brainlessdeveloper:list-style-image-computed); r=emilio

<!-- 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. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: d744e35d38ce84f7209eb1fc41d2d9f38545d0de

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 9153e9f1cad5cc33b50ca27738a194e9af010349
This commit is contained in:
Fausto Núñez Alberro 2018-04-03 18:12:13 -04:00
Родитель 9a7f6d89b0
Коммит a38b2dfb04
24 изменённых файлов: 134 добавлений и 114 удалений

Просмотреть файл

@ -52,11 +52,10 @@ use style::context::SharedStyleContext;
use style::dom::TElement;
use style::logical_geometry::Direction;
use style::properties::ComputedValues;
use style::properties::longhands::list_style_image;
use style::selector_parser::{PseudoElement, RestyleDamage};
use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::Either;
use style::values::computed::counters::ContentItem;
use style::values::generics::url::UrlOrNone as ImageUrlOrNone;
use table::TableFlow;
use table_caption::TableCaptionFlow;
use table_cell::TableCellFlow;
@ -1278,13 +1277,13 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
-> ConstructionResult {
let flotation = FloatKind::from_property(flotation);
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
list_style_image::computed_value::T(Either::First(ref url_value)) => {
ImageUrlOrNone::Url(ref url_value) => {
let image_info = Box::new(ImageFragmentInfo::new(
url_value.url().map(|u| u.clone()), node, &self.layout_context
));
vec![Fragment::new(node, SpecificFragmentInfo::Image(image_info), self.layout_context)]
}
list_style_image::computed_value::T(Either::Second(_none)) => {
ImageUrlOrNone::None => {
match ListStyleTypeContent::from_list_style_type(node.style(self.style_context())
.get_list()
.list_style_type) {

Просмотреть файл

@ -17,8 +17,9 @@ use gecko_bindings::structs::{nsStyleImage, nsresult, SheetType};
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
use std::f32::consts::PI;
use stylesheets::{Origin, RulesMutateError};
use values::computed::{Angle, CalcLengthOrPercentage, ComputedImageUrl, Gradient, Image};
use values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
use values::computed::{Integer, LengthOrPercentage, LengthOrPercentageOrAuto, Percentage, TextAlign};
use values::computed::url::ComputedImageUrl;
use values::generics::box_::VerticalAlign;
use values::generics::grid::{TrackListValue, TrackSize};
use values::generics::image::{CompatMode, Image as GenericImage, GradientItem};
@ -593,11 +594,11 @@ pub mod basic_shape {
use gecko_bindings::structs::{nsStyleCoord, nsStyleCorners};
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
use std::borrow::Borrow;
use values::computed::ComputedUrl;
use values::computed::basic_shape::{BasicShape, ClippingShape, FloatAreaShape, ShapeRadius};
use values::computed::border::{BorderCornerRadius, BorderRadius};
use values::computed::length::LengthOrPercentage;
use values::computed::position;
use values::computed::url::ComputedUrl;
use values::generics::basic_shape::{BasicShape as GenericBasicShape, InsetRect, Polygon};
use values::generics::basic_shape::{Circle, Ellipse, FillRule};
use values::generics::basic_shape::{GeometryBox, ShapeBox, ShapeSource};

Просмотреть файл

@ -66,6 +66,7 @@ use values::generics::column::ColumnCount;
use values::generics::position::ZIndex;
use values::generics::text::MozTabSize;
use values::generics::transform::TransformStyle;
use values::generics::url::UrlOrNone;
use computed_values::border_style;
pub mod style_structs {
@ -937,10 +938,10 @@ def set_gecko_property(ffi_name, expr):
#[allow(non_snake_case)]
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
match v {
Either::First(url) => {
UrlOrNone::Url(ref url) => {
self.gecko.${gecko_ffi_name}.set_move(url.url_value.clone())
}
Either::Second(_none) => {
UrlOrNone::None => {
unsafe {
self.gecko.${gecko_ffi_name}.clear();
}
@ -961,15 +962,14 @@ def set_gecko_property(ffi_name, expr):
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use values::specified::url::SpecifiedUrl;
use values::None_;
if self.gecko.${gecko_ffi_name}.mRawPtr.is_null() {
Either::Second(None_)
UrlOrNone::none()
} else {
unsafe {
let ref gecko_url_value = *self.gecko.${gecko_ffi_name}.mRawPtr;
Either::First(SpecifiedUrl::from_url_value_data(&gecko_url_value._base)
.expect("${gecko_ffi_name} could not convert to SpecifiedUrl"))
UrlOrNone::Url(SpecifiedUrl::from_url_value_data(&gecko_url_value._base)
.expect("${gecko_ffi_name} could not convert to SpecifiedUrl"))
}
}
}
@ -1469,7 +1469,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
"SVGWidth": impl_svg_length,
"Transform": impl_transform,
"TransformOrigin": impl_transform_origin,
"UrlOrNone": impl_css_url,
"url::UrlOrNone": impl_css_url,
}
def longhand_method(longhand):
@ -4061,14 +4061,13 @@ fn static_assert() {
skip_longhands="list-style-image list-style-type quotes -moz-image-region">
pub fn set_list_style_image(&mut self, image: longhands::list_style_image::computed_value::T) {
use values::Either;
match image {
longhands::list_style_image::computed_value::T(Either::Second(_none)) => {
UrlOrNone::None => {
unsafe {
Gecko_SetListStyleImageNone(&mut self.gecko);
}
}
longhands::list_style_image::computed_value::T(Either::First(ref url)) => {
UrlOrNone::Url(ref url) => {
unsafe {
Gecko_SetListStyleImageImageValue(&mut self.gecko, url.image_value.get());
}
@ -4090,20 +4089,16 @@ fn static_assert() {
pub fn clone_list_style_image(&self) -> longhands::list_style_image::computed_value::T {
use values::specified::url::SpecifiedImageUrl;
use values::{Either, None_};
longhands::list_style_image::computed_value::T(
match self.gecko.mListStyleImage.mRawPtr.is_null() {
true => Either::Second(None_),
false => {
unsafe {
let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr;
Either::First(SpecifiedImageUrl::from_image_request(gecko_image_request)
.expect("mListStyleImage could not convert to SpecifiedImageUrl"))
}
}
}
)
if self.gecko.mListStyleImage.mRawPtr.is_null() {
return UrlOrNone::None;
}
unsafe {
let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr;
UrlOrNone::Url(SpecifiedImageUrl::from_image_request(gecko_image_request)
.expect("mListStyleImage could not convert to SpecifiedImageUrl"))
}
}
pub fn set_list_style_type(&mut self, v: longhands::list_style_type::computed_value::T, device: &Device) {

Просмотреть файл

@ -36,7 +36,7 @@ use values::animated::color::RGBA as AnimatedRGBA;
use values::animated::effects::Filter as AnimatedFilter;
use values::animated::effects::FilterList as AnimatedFilterList;
use values::computed::{Angle, CalcLengthOrPercentage};
use values::computed::{ClipRect, Context, ComputedUrl};
use values::computed::{ClipRect, Context};
use values::computed::{Length, LengthOrPercentage, LengthOrPercentageOrAuto};
use values::computed::{LengthOrPercentageOrNone, MaxLength};
use values::computed::{NonNegativeNumber, Number, NumberOrPercentage, Percentage};
@ -48,6 +48,7 @@ use values::computed::transform::Transform as ComputedTransform;
use values::computed::transform::Rotate as ComputedRotate;
use values::computed::transform::Translate as ComputedTranslate;
use values::computed::transform::Scale as ComputedScale;
use values::computed::url::ComputedUrl;
use values::generics::transform::{self, Rotate, Translate, Scale, Transform, TransformOperation};
use values::distance::{ComputeSquaredDistance, SquaredDistance};
use values::generics::font::{FontSettings as GenericFontSettings, FontTag, VariationValue};

Просмотреть файл

@ -613,7 +613,7 @@ ${helpers.single_keyword("-moz-appearance",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance)",
animation_value_type="discrete")}
${helpers.predefined_type("-moz-binding", "UrlOrNone", "Either::Second(None_)",
${helpers.predefined_type("-moz-binding", "url::UrlOrNone", "computed::url::UrlOrNone::none()",
products="gecko",
animation_value_type="none",
gecko_ffi_name="mBinding",

Просмотреть файл

@ -112,17 +112,17 @@ ${helpers.single_keyword("clip-rule", "nonzero evenodd",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG11/masking.html#ClipRuleProperty")}
${helpers.predefined_type("marker-start", "UrlOrNone", "Either::Second(None_)",
${helpers.predefined_type("marker-start", "url::UrlOrNone", "computed::url::UrlOrNone::none()",
products="gecko",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
${helpers.predefined_type("marker-mid", "UrlOrNone", "Either::Second(None_)",
${helpers.predefined_type("marker-mid", "url::UrlOrNone", "computed::url::UrlOrNone::none()",
products="gecko",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}
${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
${helpers.predefined_type("marker-end", "url::UrlOrNone", "computed::url::UrlOrNone::none()",
products="gecko",
animation_value_type="discrete",
spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")}

Просмотреть файл

@ -41,9 +41,9 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
% endif
${helpers.predefined_type("list-style-image",
"ListStyleImage",
initial_value="specified::ListStyleImage::none()",
initial_specified_value="specified::ListStyleImage::none()",
"url::ImageUrlOrNone",
initial_value="computed::url::ImageUrlOrNone::none()",
initial_specified_value="specified::url::ImageUrlOrNone::none()",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image",
servo_restyle_damage="rebuild_and_reflow")}

Просмотреть файл

@ -7,7 +7,7 @@
<%helpers:shorthand name="marker" products="gecko"
sub_properties="marker-start marker-end marker-mid"
spec="https://www.w3.org/TR/SVG2/painting.html#MarkerShorthand">
use values::specified::UrlOrNone;
use values::specified::url::UrlOrNone;
pub fn parse_value<'i, 't>(
context: &ParserContext,

Просмотреть файл

@ -9,7 +9,7 @@
derive_serialize="True"
spec="https://drafts.csswg.org/css-lists/#propdef-list-style">
use properties::longhands::{list_style_image, list_style_position, list_style_type};
use values::{Either, None_};
use values::specified::url::ImageUrlOrNone;
pub fn parse_value<'i, 't>(
context: &ParserContext,
@ -76,7 +76,7 @@
(true, 2, None, None) => {
Ok(expanded! {
list_style_position: position,
list_style_image: list_style_image::SpecifiedValue(Either::Second(None_)),
list_style_image: ImageUrlOrNone::none(),
list_style_type: list_style_type_none(),
})
}
@ -90,14 +90,14 @@
(true, 1, Some(list_style_type), None) => {
Ok(expanded! {
list_style_position: position,
list_style_image: list_style_image::SpecifiedValue(Either::Second(None_)),
list_style_image: ImageUrlOrNone::none(),
list_style_type: list_style_type,
})
}
(true, 1, None, None) => {
Ok(expanded! {
list_style_position: position,
list_style_image: list_style_image::SpecifiedValue(Either::Second(None_)),
list_style_image: ImageUrlOrNone::none(),
list_style_type: list_style_type_none(),
})
}

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -493,10 +493,9 @@ mod shorthand_serialization {
}
mod list_style {
use style::properties::longhands::list_style_image::SpecifiedValue as ListStyleImage;
use style::properties::longhands::list_style_position::SpecifiedValue as ListStylePosition;
use style::properties::longhands::list_style_type::SpecifiedValue as ListStyleType;
use style::values::Either;
use style::values::generics::url::UrlOrNone as ImageUrlOrNone;
use super::*;
#[test]
@ -504,8 +503,7 @@ mod shorthand_serialization {
let mut properties = Vec::new();
let position = ListStylePosition::Inside;
let image =
ListStyleImage(Either::First(SpecifiedUrl::new_for_testing("http://servo/test.png")));
let image = ImageUrlOrNone::Url(SpecifiedUrl::new_for_testing("http://servo/test.png"));
let style_type = ListStyleType::Disc;
properties.push(PropertyDeclaration::ListStylePosition(position));