style: Remove eStyleImageType_URL.

It was introduced in bug 1352096 to reduce complexity with Stylo (apparently).

Right now it doesn't look like it reduces any complexity, and it's a bit
annoying with some of the patches that I'm writing at the moment.

So unless there's any objection I think it should go away.

Differential Revision: https://phabricator.services.mozilla.com/D31708
This commit is contained in:
Emilio Cobos Álvarez 2019-05-22 11:34:23 +00:00
parent 8bf0f82ddc
commit 431b9d00f5
4 changed files with 25 additions and 45 deletions

View file

@ -383,7 +383,6 @@ impl nsStyleImage {
let atom = bindings::Gecko_GetImageElement(self);
Some(GenericImage::Element(Atom::from_raw(atom)))
},
_ => panic!("Unexpected image type"),
}
}
@ -535,10 +534,8 @@ pub mod basic_shape {
use crate::gecko_bindings::structs::{
StyleGeometryBox, StyleShapeSource, StyleShapeSourceType,
};
use crate::gecko_bindings::sugar::refptr::RefPtr;
use crate::values::computed::basic_shape::{BasicShape, ClippingShape, FloatAreaShape};
use crate::values::computed::motion::OffsetPath;
use crate::values::computed::url::ComputedUrl;
use crate::values::generics::basic_shape::{GeometryBox, Path, ShapeBox, ShapeSource};
use crate::values::specified::SVGPathData;
@ -564,7 +561,7 @@ pub mod basic_shape {
};
Some(ShapeSource::Shape(shape, reference_box))
},
StyleShapeSourceType::URL | StyleShapeSourceType::Image => None,
StyleShapeSourceType::Image => None,
StyleShapeSourceType::Path => {
let path = self.to_svg_path().expect("expect an SVGPathData");
let fill = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr }.mFillRule;
@ -587,16 +584,15 @@ pub mod basic_shape {
impl<'a> From<&'a StyleShapeSource> for ClippingShape {
fn from(other: &'a StyleShapeSource) -> Self {
use crate::values::generics::image::Image as GenericImage;
match other.mType {
StyleShapeSourceType::URL => unsafe {
StyleShapeSourceType::Image => unsafe {
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
let other_url =
RefPtr::new(*shape_image.__bindgen_anon_1.mURLValue.as_ref() as *mut _);
let url = ComputedUrl::from_url_value(other_url);
ShapeSource::ImageOrUrl(url)
},
StyleShapeSourceType::Image => {
unreachable!("ClippingShape doesn't support Image!");
let image = shape_image.into_image().expect("Cannot convert to Image");
match image {
GenericImage::Url(url) => ShapeSource::ImageOrUrl(url.0),
_ => panic!("ClippingShape doesn't support non-url images"),
}
},
_ => other
.into_shape_source()
@ -608,9 +604,6 @@ pub mod basic_shape {
impl<'a> From<&'a StyleShapeSource> for FloatAreaShape {
fn from(other: &'a StyleShapeSource) -> Self {
match other.mType {
StyleShapeSourceType::URL => {
unreachable!("FloatAreaShape doesn't support URL!");
},
StyleShapeSourceType::Image => unsafe {
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
let image = shape_image.into_image().expect("Cannot convert to Image");
@ -632,7 +625,6 @@ pub mod basic_shape {
StyleShapeSourceType::None => OffsetPath::none(),
StyleShapeSourceType::Shape |
StyleShapeSourceType::Box |
StyleShapeSourceType::URL |
StyleShapeSourceType::Image => unreachable!("Unsupported offset-path type"),
}
}

View file

@ -310,13 +310,13 @@ impl ToComputedValue for SpecifiedImageUrl {
type ComputedValue = ComputedImageUrl;
#[inline]
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue {
ComputedImageUrl(self.clone())
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
ComputedImageUrl(self.0.to_computed_value(context))
}
#[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
computed.0.clone()
SpecifiedImageUrl(ToComputedValue::from_computed_value(&computed.0))
}
}
@ -378,7 +378,7 @@ impl ComputedUrl {
/// The computed value of a CSS image `url()`.
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)]
pub struct ComputedImageUrl(pub SpecifiedImageUrl);
pub struct ComputedImageUrl(pub ComputedUrl);
impl ToCss for ComputedImageUrl {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
@ -395,22 +395,17 @@ impl ComputedImageUrl {
/// Convert from nsStyleImageReques to ComputedImageUrl.
pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Self {
let url_value = image_request.mImageValue.to_safe();
let css_url = &*url_value.mCssUrl.mRawPtr;
let url = CssUrl(CssUrlData::as_arc(&css_url).clone_arc());
ComputedImageUrl(SpecifiedImageUrl(SpecifiedUrl {
url,
url_value: Box::new(URLValueSource::URLValue(url_value)),
}))
ComputedImageUrl(ComputedUrl::from_url_value(url_value))
}
/// Clone a new, strong reference to the Gecko URLValue.
pub fn clone_url_value(&self) -> RefPtr<URLValue> {
(self.0).0.clone_url_value()
self.0.clone_url_value()
}
/// Get a raw pointer to the URLValue held by this ComputedImageUrl, for FFI.
pub fn url_value_ptr(&self) -> *mut URLValue {
(self.0).0.url_value_ptr()
self.0.url_value_ptr()
}
}

View file

@ -53,6 +53,7 @@ use std::mem::{forget, uninitialized, zeroed, ManuallyDrop};
use std::{cmp, ops, ptr};
use crate::values::{self, CustomIdent, Either, KeyframesName, None_};
use crate::values::computed::{NonNegativeLength, Percentage, TransitionProperty};
use crate::values::computed::url::ComputedImageUrl;
use crate::values::computed::BorderStyle;
use crate::values::computed::font::FontSize;
use crate::values::computed::effects::Filter;
@ -60,6 +61,7 @@ use crate::values::generics::column::ColumnCount;
use crate::values::generics::transform::TransformStyle;
use crate::values::generics::url::UrlOrNone;
pub mod style_structs {
% for style_struct in data.style_structs:
pub use super::${style_struct.gecko_struct_name} as ${style_struct.name};
@ -2850,8 +2852,6 @@ fn static_assert() {
}
pub fn clone_list_style_image(&self) -> longhands::list_style_image::computed_value::T {
use crate::values::computed::url::ComputedImageUrl;
if self.gecko.mListStyleImage.mRawPtr.is_null() {
return UrlOrNone::None;
}
@ -3489,25 +3489,19 @@ fn set_style_svg_path(
${ident}.mType = StyleShapeSourceType::None;
match v {
% if ident == "clip_path":
ShapeSource::ImageOrUrl(ref url) => {
unsafe {
bindings::Gecko_StyleShapeSource_SetURLValue(${ident}, url.url_value_ptr())
}
}
% elif ident == "shape_outside":
ShapeSource::None => {} // don't change the type
ShapeSource::ImageOrUrl(image) => {
% if ident == "clip_path":
use crate::values::generics::image::Image;
let image = Image::Url(ComputedImageUrl(image));
% endif
unsafe {
bindings::Gecko_NewShapeImage(${ident});
let style_image = &mut *${ident}.__bindgen_anon_1.mShapeImage.as_mut().mPtr;
style_image.set(image);
}
}
% else:
<% raise Exception("Unknown property: %s" % ident) %>
}
% endif
ShapeSource::None => {} // don't change the type
ShapeSource::Box(reference) => {
${ident}.mReferenceBox = reference.into();
${ident}.mType = StyleShapeSourceType::Box;
@ -3662,7 +3656,6 @@ clip-path
pub fn clone_cursor(&self) -> longhands::cursor::computed_value::T {
use crate::values::computed::ui::CursorImage;
use crate::values::computed::url::ComputedImageUrl;
let keyword = self.gecko.mCursor;
@ -3878,7 +3871,6 @@ clip-path
use crate::gecko::conversions::string_from_chars_pointer;
use crate::gecko_bindings::structs::StyleContentType;
use crate::values::generics::counters::{Content, ContentItem};
use crate::values::computed::url::ComputedImageUrl;
use crate::values::{CustomIdent, Either};
use crate::values::generics::CounterStyleOrNone;
use crate::values::specified::Attr;

View file

@ -10,7 +10,7 @@
use crate::properties::PropertyId;
use crate::values::computed::length::LengthPercentage;
use crate::values::computed::url::ComputedUrl;
use crate::values::computed::url::{ComputedUrl, ComputedImageUrl};
use crate::values::computed::Angle as ComputedAngle;
use crate::values::computed::Image;
use crate::values::specified::SVGPathData;
@ -380,6 +380,7 @@ trivial_to_animated_value!(Au);
trivial_to_animated_value!(LengthPercentage);
trivial_to_animated_value!(ComputedAngle);
trivial_to_animated_value!(ComputedUrl);
trivial_to_animated_value!(ComputedImageUrl);
trivial_to_animated_value!(bool);
trivial_to_animated_value!(f32);
// Note: This implementation is for ToAnimatedValue of ShapeSource.