Bug 1461858 part 4 - Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl. r?emilio
MozReview-Commit-ID: LJGm3lUS9mD
--- a/servo/components/style/gecko/conversions.rs
+++ b/servo/components/style/gecko/conversions.rs
@@ -629,16 +629,17 @@ pub mod basic_shape {
//! Conversions from and to CSS shape representations.
use gecko::values::GeckoStyleCoordConvertible;
use gecko_bindings::structs;
use gecko_bindings::structs::{StyleBasicShape, StyleBasicShapeType, StyleFillRule};
use gecko_bindings::structs::{StyleGeometryBox, StyleShapeSource, StyleShapeSourceType};
use gecko_bindings::structs::{nsStyleCoord, nsStyleCorners};
use gecko_bindings::sugar::ns_style_coord::{CoordDataMut, CoordDataValue};
+ use gecko_bindings::sugar::refptr::RefPtr;
use std::borrow::Borrow;
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};
@@ -673,18 +674,18 @@ pub mod basic_shape {
}
}
impl<'a> From<&'a StyleShapeSource> for ClippingShape {
fn from(other: &'a StyleShapeSource) -> Self {
match other.mType {
StyleShapeSourceType::URL => unsafe {
let shape_image = &*other.mShapeImage.mPtr;
- let other_url = &(**shape_image.__bindgen_anon_1.mURLValue.as_ref());
- let url = ComputedUrl::from_url_value_data(&other_url._base);
+ let other_url = RefPtr::from_ptr_ref(shape_image.__bindgen_anon_1.mURLValue.as_ref());
+ let url = ComputedUrl::from_url_value(other_url.clone());
ShapeSource::ImageOrUrl(url)
},
StyleShapeSourceType::Image => {
unreachable!("ClippingShape doesn't support Image!");
},
_ => other
.into_shape_source()
.expect("Couldn't convert to StyleSource!"),
--- a/servo/components/style/gecko/url.rs
+++ b/servo/components/style/gecko/url.rs
@@ -282,21 +282,20 @@ impl ToCss for ComputedUrl {
where
W: Write
{
serialize_computed_url(&self.0.url_value._base, dest)
}
}
impl ComputedUrl {
- /// Convert from URLValueData to ComputedUrl.
- pub unsafe fn from_url_value_data(url: &URLValueData) -> Self {
- ComputedUrl(
- SpecifiedUrl::from_css_url(CssUrl::from_url_value_data(url))
- )
+ /// Convert from RefPtr<URLValue> to ComputedUrl.
+ pub unsafe fn from_url_value(url_value: RefPtr<URLValue>) -> Self {
+ let url = CssUrl::from_url_value_data(&url_value._base);
+ ComputedUrl(SpecifiedUrl { url, url_value })
}
}
/// The computed value of a CSS `url()` for image.
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)]
pub struct ComputedImageUrl(pub SpecifiedImageUrl);
impl ToCss for ComputedImageUrl {
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -38,16 +38,17 @@ use gecko_bindings::bindings::Gecko_SetN
use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
use gecko_bindings::bindings::RawGeckoPresContextBorrowed;
use gecko_bindings::structs;
use gecko_bindings::structs::nsCSSPropertyID;
use gecko_bindings::structs::mozilla::CSSPseudoElementType;
use gecko_bindings::structs::mozilla::CSSPseudoElementType_InheritingAnonBox;
use gecko_bindings::structs::root::NS_STYLE_CONTEXT_TYPE_SHIFT;
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
+use gecko_bindings::sugar::refptr::RefPtr;
use gecko::values::convert_nscolor_to_rgba;
use gecko::values::convert_rgba_to_nscolor;
use gecko::values::GeckoStyleCoordConvertible;
use gecko::values::round_border_to_device_pixels;
use logical_geometry::WritingMode;
use media_queries::Device;
use properties::animated_properties::TransitionProperty;
use properties::computed_value_flags::*;
@@ -753,23 +754,20 @@ def set_gecko_property(ffi_name, expr):
nsStyleSVGFallbackType::eStyleSVGFallbackType_NotSet => None,
};
let kind = match paint.mType {
nsStyleSVGPaintType::eStyleSVGPaintType_None => SVGPaintKind::None,
nsStyleSVGPaintType::eStyleSVGPaintType_ContextFill => SVGPaintKind::ContextFill,
nsStyleSVGPaintType::eStyleSVGPaintType_ContextStroke => SVGPaintKind::ContextStroke,
nsStyleSVGPaintType::eStyleSVGPaintType_Server => {
- unsafe {
- SVGPaintKind::PaintServer(
- ComputedUrl::from_url_value_data(
- &(**paint.mPaint.mPaintServer.as_ref())._base
- )
- )
- }
+ SVGPaintKind::PaintServer(unsafe {
+ let url = RefPtr::from_ptr_ref(paint.mPaint.mPaintServer.as_ref());
+ ComputedUrl::from_url_value(url.clone())
+ })
}
nsStyleSVGPaintType::eStyleSVGPaintType_Color => {
unsafe { SVGPaintKind::Color(convert_nscolor_to_rgba(*paint.mPaint.mColor.as_ref())) }
}
};
SVGPaint {
kind: kind,
fallback: fallback,
@@ -962,22 +960,19 @@ def set_gecko_property(ffi_name, expr):
#[allow(non_snake_case)]
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
use values::computed::url::ComputedUrl;
if self.gecko.${gecko_ffi_name}.mRawPtr.is_null() {
return UrlOrNone::none()
}
- unsafe {
- let gecko_url_value = &*self.gecko.${gecko_ffi_name}.mRawPtr;
- UrlOrNone::Url(
- ComputedUrl::from_url_value_data(&gecko_url_value._base)
- )
- }
+ UrlOrNone::Url(unsafe {
+ ComputedUrl::from_url_value(self.gecko.${gecko_ffi_name}.to_safe())
+ })
}
</%def>
<%
transform_functions = [
("Matrix3D", "matrix3d", ["number"] * 16),
("Matrix", "matrix", ["number"] * 6),
("Translate", "translate", ["lop", "optional_lop"]),
@@ -4545,21 +4540,20 @@ fn static_assert() {
NS_STYLE_FILTER_DROP_SHADOW => {
filters.push(unsafe {
Filter::DropShadow(
(**filter.__bindgen_anon_1.mDropShadow.as_ref()).mArray[0].to_simple_shadow(),
)
});
},
NS_STYLE_FILTER_URL => {
- filters.push(unsafe {
- Filter::Url(
- ComputedUrl::from_url_value_data(&(**filter.__bindgen_anon_1.mURL.as_ref())._base)
- )
- });
+ filters.push(Filter::Url(unsafe {
+ let url = RefPtr::from_ptr_ref(filter.__bindgen_anon_1.mURL.as_ref());
+ ComputedUrl::from_url_value(url.clone())
+ }));
}
_ => {},
}
}
longhands::filter::computed_value::T(filters)
}
</%self:impl_trait>