mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
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:
parent
8bf0f82ddc
commit
431b9d00f5
4 changed files with 25 additions and 45 deletions
|
@ -383,7 +383,6 @@ impl nsStyleImage {
|
||||||
let atom = bindings::Gecko_GetImageElement(self);
|
let atom = bindings::Gecko_GetImageElement(self);
|
||||||
Some(GenericImage::Element(Atom::from_raw(atom)))
|
Some(GenericImage::Element(Atom::from_raw(atom)))
|
||||||
},
|
},
|
||||||
_ => panic!("Unexpected image type"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,10 +534,8 @@ pub mod basic_shape {
|
||||||
use crate::gecko_bindings::structs::{
|
use crate::gecko_bindings::structs::{
|
||||||
StyleGeometryBox, StyleShapeSource, StyleShapeSourceType,
|
StyleGeometryBox, StyleShapeSource, StyleShapeSourceType,
|
||||||
};
|
};
|
||||||
use crate::gecko_bindings::sugar::refptr::RefPtr;
|
|
||||||
use crate::values::computed::basic_shape::{BasicShape, ClippingShape, FloatAreaShape};
|
use crate::values::computed::basic_shape::{BasicShape, ClippingShape, FloatAreaShape};
|
||||||
use crate::values::computed::motion::OffsetPath;
|
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::generics::basic_shape::{GeometryBox, Path, ShapeBox, ShapeSource};
|
||||||
use crate::values::specified::SVGPathData;
|
use crate::values::specified::SVGPathData;
|
||||||
|
|
||||||
|
@ -564,7 +561,7 @@ pub mod basic_shape {
|
||||||
};
|
};
|
||||||
Some(ShapeSource::Shape(shape, reference_box))
|
Some(ShapeSource::Shape(shape, reference_box))
|
||||||
},
|
},
|
||||||
StyleShapeSourceType::URL | StyleShapeSourceType::Image => None,
|
StyleShapeSourceType::Image => None,
|
||||||
StyleShapeSourceType::Path => {
|
StyleShapeSourceType::Path => {
|
||||||
let path = self.to_svg_path().expect("expect an SVGPathData");
|
let path = self.to_svg_path().expect("expect an SVGPathData");
|
||||||
let fill = unsafe { &*self.__bindgen_anon_1.mSVGPath.as_ref().mPtr }.mFillRule;
|
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 {
|
impl<'a> From<&'a StyleShapeSource> for ClippingShape {
|
||||||
fn from(other: &'a StyleShapeSource) -> Self {
|
fn from(other: &'a StyleShapeSource) -> Self {
|
||||||
|
use crate::values::generics::image::Image as GenericImage;
|
||||||
match other.mType {
|
match other.mType {
|
||||||
StyleShapeSourceType::URL => unsafe {
|
StyleShapeSourceType::Image => unsafe {
|
||||||
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
|
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
|
||||||
let other_url =
|
let image = shape_image.into_image().expect("Cannot convert to Image");
|
||||||
RefPtr::new(*shape_image.__bindgen_anon_1.mURLValue.as_ref() as *mut _);
|
match image {
|
||||||
let url = ComputedUrl::from_url_value(other_url);
|
GenericImage::Url(url) => ShapeSource::ImageOrUrl(url.0),
|
||||||
ShapeSource::ImageOrUrl(url)
|
_ => panic!("ClippingShape doesn't support non-url images"),
|
||||||
},
|
}
|
||||||
StyleShapeSourceType::Image => {
|
|
||||||
unreachable!("ClippingShape doesn't support Image!");
|
|
||||||
},
|
},
|
||||||
_ => other
|
_ => other
|
||||||
.into_shape_source()
|
.into_shape_source()
|
||||||
|
@ -608,9 +604,6 @@ pub mod basic_shape {
|
||||||
impl<'a> From<&'a StyleShapeSource> for FloatAreaShape {
|
impl<'a> From<&'a StyleShapeSource> for FloatAreaShape {
|
||||||
fn from(other: &'a StyleShapeSource) -> Self {
|
fn from(other: &'a StyleShapeSource) -> Self {
|
||||||
match other.mType {
|
match other.mType {
|
||||||
StyleShapeSourceType::URL => {
|
|
||||||
unreachable!("FloatAreaShape doesn't support URL!");
|
|
||||||
},
|
|
||||||
StyleShapeSourceType::Image => unsafe {
|
StyleShapeSourceType::Image => unsafe {
|
||||||
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
|
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
|
||||||
let image = shape_image.into_image().expect("Cannot convert to Image");
|
let image = shape_image.into_image().expect("Cannot convert to Image");
|
||||||
|
@ -632,7 +625,6 @@ pub mod basic_shape {
|
||||||
StyleShapeSourceType::None => OffsetPath::none(),
|
StyleShapeSourceType::None => OffsetPath::none(),
|
||||||
StyleShapeSourceType::Shape |
|
StyleShapeSourceType::Shape |
|
||||||
StyleShapeSourceType::Box |
|
StyleShapeSourceType::Box |
|
||||||
StyleShapeSourceType::URL |
|
|
||||||
StyleShapeSourceType::Image => unreachable!("Unsupported offset-path type"),
|
StyleShapeSourceType::Image => unreachable!("Unsupported offset-path type"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,13 +310,13 @@ impl ToComputedValue for SpecifiedImageUrl {
|
||||||
type ComputedValue = ComputedImageUrl;
|
type ComputedValue = ComputedImageUrl;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue {
|
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||||
ComputedImageUrl(self.clone())
|
ComputedImageUrl(self.0.to_computed_value(context))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
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()`.
|
/// The computed value of a CSS image `url()`.
|
||||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)]
|
||||||
pub struct ComputedImageUrl(pub SpecifiedImageUrl);
|
pub struct ComputedImageUrl(pub ComputedUrl);
|
||||||
|
|
||||||
impl ToCss for ComputedImageUrl {
|
impl ToCss for ComputedImageUrl {
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||||
|
@ -395,22 +395,17 @@ impl ComputedImageUrl {
|
||||||
/// Convert from nsStyleImageReques to ComputedImageUrl.
|
/// Convert from nsStyleImageReques to ComputedImageUrl.
|
||||||
pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Self {
|
pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Self {
|
||||||
let url_value = image_request.mImageValue.to_safe();
|
let url_value = image_request.mImageValue.to_safe();
|
||||||
let css_url = &*url_value.mCssUrl.mRawPtr;
|
ComputedImageUrl(ComputedUrl::from_url_value(url_value))
|
||||||
let url = CssUrl(CssUrlData::as_arc(&css_url).clone_arc());
|
|
||||||
ComputedImageUrl(SpecifiedImageUrl(SpecifiedUrl {
|
|
||||||
url,
|
|
||||||
url_value: Box::new(URLValueSource::URLValue(url_value)),
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clone a new, strong reference to the Gecko URLValue.
|
/// Clone a new, strong reference to the Gecko URLValue.
|
||||||
pub fn clone_url_value(&self) -> RefPtr<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.
|
/// Get a raw pointer to the URLValue held by this ComputedImageUrl, for FFI.
|
||||||
pub fn url_value_ptr(&self) -> *mut URLValue {
|
pub fn url_value_ptr(&self) -> *mut URLValue {
|
||||||
(self.0).0.url_value_ptr()
|
self.0.url_value_ptr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ use std::mem::{forget, uninitialized, zeroed, ManuallyDrop};
|
||||||
use std::{cmp, ops, ptr};
|
use std::{cmp, ops, ptr};
|
||||||
use crate::values::{self, CustomIdent, Either, KeyframesName, None_};
|
use crate::values::{self, CustomIdent, Either, KeyframesName, None_};
|
||||||
use crate::values::computed::{NonNegativeLength, Percentage, TransitionProperty};
|
use crate::values::computed::{NonNegativeLength, Percentage, TransitionProperty};
|
||||||
|
use crate::values::computed::url::ComputedImageUrl;
|
||||||
use crate::values::computed::BorderStyle;
|
use crate::values::computed::BorderStyle;
|
||||||
use crate::values::computed::font::FontSize;
|
use crate::values::computed::font::FontSize;
|
||||||
use crate::values::computed::effects::Filter;
|
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::transform::TransformStyle;
|
||||||
use crate::values::generics::url::UrlOrNone;
|
use crate::values::generics::url::UrlOrNone;
|
||||||
|
|
||||||
|
|
||||||
pub mod style_structs {
|
pub mod style_structs {
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
pub use super::${style_struct.gecko_struct_name} as ${style_struct.name};
|
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 {
|
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() {
|
if self.gecko.mListStyleImage.mRawPtr.is_null() {
|
||||||
return UrlOrNone::None;
|
return UrlOrNone::None;
|
||||||
}
|
}
|
||||||
|
@ -3489,25 +3489,19 @@ fn set_style_svg_path(
|
||||||
${ident}.mType = StyleShapeSourceType::None;
|
${ident}.mType = StyleShapeSourceType::None;
|
||||||
|
|
||||||
match v {
|
match v {
|
||||||
% if ident == "clip_path":
|
ShapeSource::None => {} // don't change the type
|
||||||
ShapeSource::ImageOrUrl(ref url) => {
|
|
||||||
unsafe {
|
|
||||||
bindings::Gecko_StyleShapeSource_SetURLValue(${ident}, url.url_value_ptr())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
% elif ident == "shape_outside":
|
|
||||||
ShapeSource::ImageOrUrl(image) => {
|
ShapeSource::ImageOrUrl(image) => {
|
||||||
|
% if ident == "clip_path":
|
||||||
|
use crate::values::generics::image::Image;
|
||||||
|
|
||||||
|
let image = Image::Url(ComputedImageUrl(image));
|
||||||
|
% endif
|
||||||
unsafe {
|
unsafe {
|
||||||
bindings::Gecko_NewShapeImage(${ident});
|
bindings::Gecko_NewShapeImage(${ident});
|
||||||
let style_image = &mut *${ident}.__bindgen_anon_1.mShapeImage.as_mut().mPtr;
|
let style_image = &mut *${ident}.__bindgen_anon_1.mShapeImage.as_mut().mPtr;
|
||||||
style_image.set(image);
|
style_image.set(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
% else:
|
|
||||||
<% raise Exception("Unknown property: %s" % ident) %>
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
ShapeSource::None => {} // don't change the type
|
|
||||||
ShapeSource::Box(reference) => {
|
ShapeSource::Box(reference) => {
|
||||||
${ident}.mReferenceBox = reference.into();
|
${ident}.mReferenceBox = reference.into();
|
||||||
${ident}.mType = StyleShapeSourceType::Box;
|
${ident}.mType = StyleShapeSourceType::Box;
|
||||||
|
@ -3662,7 +3656,6 @@ clip-path
|
||||||
|
|
||||||
pub fn clone_cursor(&self) -> longhands::cursor::computed_value::T {
|
pub fn clone_cursor(&self) -> longhands::cursor::computed_value::T {
|
||||||
use crate::values::computed::ui::CursorImage;
|
use crate::values::computed::ui::CursorImage;
|
||||||
use crate::values::computed::url::ComputedImageUrl;
|
|
||||||
|
|
||||||
let keyword = self.gecko.mCursor;
|
let keyword = self.gecko.mCursor;
|
||||||
|
|
||||||
|
@ -3878,7 +3871,6 @@ clip-path
|
||||||
use crate::gecko::conversions::string_from_chars_pointer;
|
use crate::gecko::conversions::string_from_chars_pointer;
|
||||||
use crate::gecko_bindings::structs::StyleContentType;
|
use crate::gecko_bindings::structs::StyleContentType;
|
||||||
use crate::values::generics::counters::{Content, ContentItem};
|
use crate::values::generics::counters::{Content, ContentItem};
|
||||||
use crate::values::computed::url::ComputedImageUrl;
|
|
||||||
use crate::values::{CustomIdent, Either};
|
use crate::values::{CustomIdent, Either};
|
||||||
use crate::values::generics::CounterStyleOrNone;
|
use crate::values::generics::CounterStyleOrNone;
|
||||||
use crate::values::specified::Attr;
|
use crate::values::specified::Attr;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
use crate::properties::PropertyId;
|
use crate::properties::PropertyId;
|
||||||
use crate::values::computed::length::LengthPercentage;
|
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::Angle as ComputedAngle;
|
||||||
use crate::values::computed::Image;
|
use crate::values::computed::Image;
|
||||||
use crate::values::specified::SVGPathData;
|
use crate::values::specified::SVGPathData;
|
||||||
|
@ -380,6 +380,7 @@ trivial_to_animated_value!(Au);
|
||||||
trivial_to_animated_value!(LengthPercentage);
|
trivial_to_animated_value!(LengthPercentage);
|
||||||
trivial_to_animated_value!(ComputedAngle);
|
trivial_to_animated_value!(ComputedAngle);
|
||||||
trivial_to_animated_value!(ComputedUrl);
|
trivial_to_animated_value!(ComputedUrl);
|
||||||
|
trivial_to_animated_value!(ComputedImageUrl);
|
||||||
trivial_to_animated_value!(bool);
|
trivial_to_animated_value!(bool);
|
||||||
trivial_to_animated_value!(f32);
|
trivial_to_animated_value!(f32);
|
||||||
// Note: This implementation is for ToAnimatedValue of ShapeSource.
|
// Note: This implementation is for ToAnimatedValue of ShapeSource.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue