From dc2aadd43a6c716227988dcf938924081224819a Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 16 May 2018 12:19:31 +1000 Subject: [PATCH 1/7] style: Make creating CssUrl infallible. There were a check in CssUrl::parse_from_string for extra data, which was removed as part of servo/servo#16241, so it never fails now. CssUrl::from_url_value_data doesn't seem to need Result from the very beginning. It is unclear why it was made that way. Bug: 1461858 Reviewed-by: emilio MozReview-Commit-ID: LXzKlZ6wPYW --- components/style/gecko/conversions.rs | 3 +- components/style/gecko/url.rs | 44 +++++++++------------ components/style/properties/gecko.mako.rs | 5 +-- components/style/servo/url.rs | 14 +++---- components/style/stylesheets/rule_parser.rs | 2 +- components/style/values/specified/image.rs | 2 +- 6 files changed, 28 insertions(+), 42 deletions(-) diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs index 951360b8f5e..76faf2a44ba 100644 --- a/components/style/gecko/conversions.rs +++ b/components/style/gecko/conversions.rs @@ -429,7 +429,6 @@ impl nsStyleImage { unsafe fn get_image_url(self: &nsStyleImage) -> ComputedImageUrl { let url_value = bindings::Gecko_GetURLValue(self); ComputedImageUrl::from_url_value_data(url_value.as_ref().unwrap()) - .expect("Could not convert to ComputedUrl") } unsafe fn get_gradient(self: &nsStyleImage) -> Box { @@ -679,7 +678,7 @@ pub mod basic_shape { 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).unwrap(); + let url = ComputedUrl::from_url_value_data(&other_url._base); ShapeSource::ImageOrUrl(url) }, StyleShapeSourceType::Image => { diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index d371f0a74e5..f127e16a9bd 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -38,16 +38,11 @@ pub struct CssUrl { impl CssUrl { /// Try to parse a URL from a string value that is a valid CSS token for a /// URL. - /// - /// Returns `Err` in the case that extra_data is incomplete. - pub fn parse_from_string<'a>( - url: String, - context: &ParserContext, - ) -> Result> { - Ok(CssUrl { + pub fn parse_from_string(url: String, context: &ParserContext) -> Self { + CssUrl { serialization: Arc::new(url), extra_data: context.url_data.clone(), - }) + } } /// Returns true if the URL is definitely invalid. We don't eagerly resolve @@ -58,13 +53,13 @@ impl CssUrl { } /// Convert from URLValueData to SpecifiedUrl. - unsafe fn from_url_value_data(url: &URLValueData) -> Result { + unsafe fn from_url_value_data(url: &URLValueData) -> Self { let arc_type = &url.mString as *const _ as *const RawOffsetArc; - Ok(CssUrl { + CssUrl { serialization: Arc::from_raw_offset((*arc_type).clone()), extra_data: url.mExtraData.to_safe(), - }) + } } /// Returns true if this URL looks like a fragment. @@ -104,7 +99,7 @@ impl Parse for CssUrl { input: &mut Parser<'i, 't>, ) -> Result> { let url = input.expect_url()?; - Self::parse_from_string(url.as_ref().to_owned(), context) + Ok(Self::parse_from_string(url.as_ref().to_owned(), context)) } } @@ -188,11 +183,8 @@ pub struct SpecifiedImageUrl { impl SpecifiedImageUrl { /// Parse a URL from a string value. See SpecifiedUrl::parse_from_string. - pub fn parse_from_string<'a>( - url: String, - context: &ParserContext, - ) -> Result> { - CssUrl::parse_from_string(url, context).map(Self::from_css_url) + pub fn parse_from_string(url: String, context: &ParserContext) -> Self { + Self::from_css_url(CssUrl::parse_from_string(url, context)) } fn from_css_url(url: CssUrl) -> Self { @@ -296,10 +288,10 @@ impl ToCss for ComputedUrl { impl ComputedUrl { /// Convert from URLValueData to ComputedUrl. - pub unsafe fn from_url_value_data(url: &URLValueData) -> Result { - Ok(ComputedUrl( - SpecifiedUrl::from_css_url(CssUrl::from_url_value_data(url)?) - )) + pub unsafe fn from_url_value_data(url: &URLValueData) -> Self { + ComputedUrl( + SpecifiedUrl::from_css_url(CssUrl::from_url_value_data(url)) + ) } } @@ -318,10 +310,10 @@ impl ToCss for ComputedImageUrl { impl ComputedImageUrl { /// Convert from URLValueData to SpecifiedUrl. - pub unsafe fn from_url_value_data(url: &URLValueData) -> Result { - Ok(ComputedImageUrl( - SpecifiedImageUrl::from_css_url(CssUrl::from_url_value_data(url)?) - )) + pub unsafe fn from_url_value_data(url: &URLValueData) -> Self { + ComputedImageUrl( + SpecifiedImageUrl::from_css_url(CssUrl::from_url_value_data(url)) + ) } /// Convert from nsStyleImageReques to ComputedImageUrl. @@ -332,6 +324,6 @@ impl ComputedImageUrl { let image_value = image_request.mImageValue.mRawPtr.as_ref().unwrap(); let url_value_data = &image_value._base; - Self::from_url_value_data(url_value_data) + Ok(Self::from_url_value_data(url_value_data)) } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 3f20b8328bd..7d17c8111dd 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -762,7 +762,7 @@ def set_gecko_property(ffi_name, expr): SVGPaintKind::PaintServer( ComputedUrl::from_url_value_data( &(**paint.mPaint.mPaintServer.as_ref())._base - ).unwrap() + ) ) } } @@ -971,7 +971,6 @@ def set_gecko_property(ffi_name, expr): let gecko_url_value = &*self.gecko.${gecko_ffi_name}.mRawPtr; UrlOrNone::Url( ComputedUrl::from_url_value_data(&gecko_url_value._base) - .expect("${gecko_ffi_name} could not convert to ComputedUrl") ) } } @@ -4555,7 +4554,7 @@ fn static_assert() { NS_STYLE_FILTER_URL => { filters.push(unsafe { Filter::Url( - ComputedUrl::from_url_value_data(&(**filter.__bindgen_anon_1.mURL.as_ref())._base).unwrap() + ComputedUrl::from_url_value_data(&(**filter.__bindgen_anon_1.mURL.as_ref())._base) ) }); } diff --git a/components/style/servo/url.rs b/components/style/servo/url.rs index c0867122ae3..b4821f21e66 100644 --- a/components/style/servo/url.rs +++ b/components/style/servo/url.rs @@ -40,18 +40,14 @@ pub struct CssUrl { impl CssUrl { /// Try to parse a URL from a string value that is a valid CSS token for a - /// URL. Never fails - the API is only fallible to be compatible with the - /// gecko version. - pub fn parse_from_string<'a>( - url: String, - context: &ParserContext, - ) -> Result> { + /// URL. + pub fn parse_from_string(url: String, context: &ParserContext) -> Self { let serialization = Arc::new(url); let resolved = context.url_data.join(&serialization).ok(); - Ok(CssUrl { + CssUrl { original: Some(serialization), resolved: resolved, - }) + } } /// Returns true if the URL is definitely invalid. For Servo URLs, we can @@ -110,7 +106,7 @@ impl Parse for CssUrl { input: &mut Parser<'i, 't>, ) -> Result> { let url = input.expect_url()?; - Self::parse_from_string(url.as_ref().to_owned(), context) + Ok(Self::parse_from_string(url.as_ref().to_owned(), context)) } } diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index 3444dd62614..93f0eaab650 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -158,7 +158,7 @@ impl<'a, 'i, R: ParseErrorReporter> AtRuleParser<'i> for TopLevelRuleParser<'a, } let url_string = input.expect_url_or_string()?.as_ref().to_owned(); - let url = CssUrl::parse_from_string(url_string, &self.context)?; + let url = CssUrl::parse_from_string(url_string, &self.context); let media = parse_media_query_list(&self.context, input, self.error_context.error_reporter); diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index f00b9b53f3c..2390292253b 100644 --- a/components/style/values/specified/image.rs +++ b/components/style/values/specified/image.rs @@ -990,7 +990,7 @@ impl Parse for MozImageRect { input.try(|i| i.expect_function_matching("-moz-image-rect"))?; input.parse_nested_block(|i| { let string = i.expect_url_or_string()?; - let url = SpecifiedImageUrl::parse_from_string(string.as_ref().to_owned(), context)?; + let url = SpecifiedImageUrl::parse_from_string(string.as_ref().to_owned(), context); i.expect_comma()?; let top = NumberOrPercentage::parse_non_negative(context, i)?; i.expect_comma()?; From 45a37503afd3d712c9c69d7745a9f80d1b127bbf Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 16 May 2018 13:39:58 +1000 Subject: [PATCH 2/7] style: Make from_image_request infallible. All callsites already assert, so moving the assertion into the method should be fine. It is not expected to handle a null image value anyway. Bug: 1461858 Reviewed-by: emilio MozReview-Commit-ID: J8CA8m22eSv --- components/style/gecko/url.rs | 11 ++++------- components/style/properties/gecko.mako.rs | 6 +----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index f127e16a9bd..102f59dad9c 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -317,13 +317,10 @@ impl ComputedImageUrl { } /// Convert from nsStyleImageReques to ComputedImageUrl. - pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Result { - if image_request.mImageValue.mRawPtr.is_null() { - return Err(()); - } - - let image_value = image_request.mImageValue.mRawPtr.as_ref().unwrap(); + pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Self { + let image_value = image_request.mImageValue.mRawPtr + .as_ref().expect("mImageValue is null"); let url_value_data = &image_value._base; - Ok(Self::from_url_value_data(url_value_data)) + Self::from_url_value_data(url_value_data) } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 7d17c8111dd..2f091b8d5ab 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -4145,9 +4145,7 @@ fn static_assert() { unsafe { let ref gecko_image_request = *self.gecko.mListStyleImage.mRawPtr; - UrlOrNone::Url(ComputedImageUrl::from_image_request( - gecko_image_request - ).expect("mListStyleImage could not convert to ComputedImageUrl")) + UrlOrNone::Url(ComputedImageUrl::from_image_request(gecko_image_request)) } } @@ -5437,7 +5435,6 @@ clip-path let url = unsafe { let gecko_image_request = gecko_cursor_image.mImage.mRawPtr.as_ref().unwrap(); ComputedImageUrl::from_image_request(&gecko_image_request) - .expect("mCursorImages.mImage could not convert to ComputedImageUrl") }; let hotspot = @@ -5713,7 +5710,6 @@ clip-path &**gecko_content.mContent.mImage.as_ref(); ContentItem::Url( ComputedImageUrl::from_image_request(gecko_image_request) - .expect("mContent could not convert to ComputedImageUrl") ) } }, From 5b0903e604e477203af9b177d92b4783898d1abe Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 16 May 2018 14:01:25 +1000 Subject: [PATCH 3/7] style: Have from_image_request reuse ImageValue from image request directly. And also remove ComputedImageUrl::from_url_value_data. Bug: 1461858 Reviewed-by: emilio MozReview-Commit-ID: 5zifQlU7tOz --- components/style/gecko/conversions.rs | 7 ++++--- components/style/gecko/url.rs | 14 +++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs index 76faf2a44ba..bb0ea1e5013 100644 --- a/components/style/gecko/conversions.rs +++ b/components/style/gecko/conversions.rs @@ -426,9 +426,10 @@ impl nsStyleImage { } } - unsafe fn get_image_url(self: &nsStyleImage) -> ComputedImageUrl { - let url_value = bindings::Gecko_GetURLValue(self); - ComputedImageUrl::from_url_value_data(url_value.as_ref().unwrap()) + unsafe fn get_image_url(&self) -> ComputedImageUrl { + let image_request = bindings::Gecko_GetImageRequest(self) + .as_ref().expect("Null image request?"); + ComputedImageUrl::from_image_request(image_request) } unsafe fn get_gradient(self: &nsStyleImage) -> Box { diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index 102f59dad9c..163c1690523 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -309,18 +309,10 @@ impl ToCss for ComputedImageUrl { } impl ComputedImageUrl { - /// Convert from URLValueData to SpecifiedUrl. - pub unsafe fn from_url_value_data(url: &URLValueData) -> Self { - ComputedImageUrl( - SpecifiedImageUrl::from_css_url(CssUrl::from_url_value_data(url)) - ) - } - /// Convert from nsStyleImageReques to ComputedImageUrl. pub unsafe fn from_image_request(image_request: &nsStyleImageRequest) -> Self { - let image_value = image_request.mImageValue.mRawPtr - .as_ref().expect("mImageValue is null"); - let url_value_data = &image_value._base; - Self::from_url_value_data(url_value_data) + let image_value = image_request.mImageValue.to_safe(); + let url = CssUrl::from_url_value_data(&image_value._base); + ComputedImageUrl(SpecifiedImageUrl { url, image_value }) } } From ecb2ec63de0ef76c15cb1ccf9d8a2d9c438c97c4 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 16 May 2018 14:35:37 +1000 Subject: [PATCH 4/7] style: Rename from_url_value_data to from_url_value and reuse URLValue passed in for ComputedUrl. Bug: 1461858 Reviewed-by: emilio MozReview-Commit-ID: LJGm3lUS9mD --- components/style/gecko/conversions.rs | 5 ++-- components/style/gecko/url.rs | 9 +++---- components/style/properties/gecko.mako.rs | 30 +++++++++-------------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs index bb0ea1e5013..314ded9cb1c 100644 --- a/components/style/gecko/conversions.rs +++ b/components/style/gecko/conversions.rs @@ -634,6 +634,7 @@ pub mod basic_shape { 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}; @@ -678,8 +679,8 @@ pub mod basic_shape { 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 => { diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index 163c1690523..cb503f4720a 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -287,11 +287,10 @@ impl ToCss for ComputedUrl { } 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 to ComputedUrl. + pub unsafe fn from_url_value(url_value: RefPtr) -> Self { + let url = CssUrl::from_url_value_data(&url_value._base); + ComputedUrl(SpecifiedUrl { url, url_value }) } } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 2f091b8d5ab..bb71edaa7c3 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -43,6 +43,7 @@ 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; @@ -758,13 +759,10 @@ def set_gecko_property(ffi_name, expr): 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())) } @@ -967,12 +965,9 @@ def set_gecko_property(ffi_name, expr): 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()) + }) } @@ -4550,11 +4545,10 @@ fn static_assert() { }); }, 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()) + })); } _ => {}, } From 514aba51adc0fb0558881ae91832153d7586ddb3 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 16 May 2018 22:21:57 +1000 Subject: [PATCH 5/7] style: Use RefPtr::new instead of RefPtr::from_ptr_ref + clone. Bug: 1461858 Reviewed-by: emilio --- components/style/gecko/conversions.rs | 4 ++-- components/style/properties/gecko.mako.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/style/gecko/conversions.rs b/components/style/gecko/conversions.rs index 314ded9cb1c..bbc2776daa9 100644 --- a/components/style/gecko/conversions.rs +++ b/components/style/gecko/conversions.rs @@ -679,8 +679,8 @@ pub mod basic_shape { match other.mType { StyleShapeSourceType::URL => unsafe { let shape_image = &*other.mShapeImage.mPtr; - let other_url = RefPtr::from_ptr_ref(shape_image.__bindgen_anon_1.mURLValue.as_ref()); - let url = ComputedUrl::from_url_value(other_url.clone()); + let other_url = RefPtr::new(*shape_image.__bindgen_anon_1.mURLValue.as_ref()); + let url = ComputedUrl::from_url_value(other_url); ShapeSource::ImageOrUrl(url) }, StyleShapeSourceType::Image => { diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index bb71edaa7c3..b86a59fc6e5 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -760,8 +760,8 @@ def set_gecko_property(ffi_name, expr): nsStyleSVGPaintType::eStyleSVGPaintType_ContextStroke => SVGPaintKind::ContextStroke, nsStyleSVGPaintType::eStyleSVGPaintType_Server => { SVGPaintKind::PaintServer(unsafe { - let url = RefPtr::from_ptr_ref(paint.mPaint.mPaintServer.as_ref()); - ComputedUrl::from_url_value(url.clone()) + let url = RefPtr::new(*paint.mPaint.mPaintServer.as_ref()); + ComputedUrl::from_url_value(url) }) } nsStyleSVGPaintType::eStyleSVGPaintType_Color => { @@ -4546,8 +4546,8 @@ fn static_assert() { }, NS_STYLE_FILTER_URL => { filters.push(Filter::Url(unsafe { - let url = RefPtr::from_ptr_ref(filter.__bindgen_anon_1.mURL.as_ref()); - ComputedUrl::from_url_value(url.clone()) + let url = RefPtr::new(*filter.__bindgen_anon_1.mURL.as_ref()); + ComputedUrl::from_url_value(url) })); } _ => {}, From 34722c3de93264c442dc8621c630e65340a3ca9a Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Thu, 17 May 2018 17:30:35 +0200 Subject: [PATCH 6/7] style: Inlinify display:list-item to display:inline for now, until we support 'display:inline list-item' properly. Bug: 1461039 Reviewed-by: xidorn --- components/style/values/specified/box.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index f56d6afd430..d716e9e6798 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -212,6 +212,8 @@ impl Display { Display::Table => Display::InlineTable, Display::Flex => Display::InlineFlex, Display::Grid => Display::InlineGrid, + // XXX bug 1105868 this should probably be InlineListItem: + Display::ListItem => Display::Inline, Display::MozBox => Display::MozInlineBox, Display::MozStack => Display::MozInlineStack, Display::WebkitBox => Display::WebkitInlineBox, From fade636ebeab55e9e7158a25abf117d86dad2130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 20 May 2018 20:10:11 +0200 Subject: [PATCH 7/7] style: Fix Gecko build after #20506. --- components/style/properties/gecko.mako.rs | 10 ++++++++-- components/style/properties/longhand/font.mako.rs | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index b86a59fc6e5..3d9a8e579af 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -2607,10 +2607,16 @@ fn static_assert() { } pub fn set_font_stretch(&mut self, v: longhands::font_stretch::computed_value::T) { - unsafe { bindings::Gecko_FontStretch_SetFloat(&mut self.gecko.mFont.stretch, (v.0).0) }; + unsafe { + bindings::Gecko_FontStretch_SetFloat( + &mut self.gecko.mFont.stretch, + v.value(), + ) + }; } ${impl_simple_copy('font_stretch', 'mFont.stretch')} pub fn clone_font_stretch(&self) -> longhands::font_stretch::computed_value::T { + use values::computed::font::FontStretch; use values::computed::Percentage; use values::generics::NonNegative; @@ -2618,7 +2624,7 @@ fn static_assert() { unsafe { bindings::Gecko_FontStretch_ToFloat(self.gecko.mFont.stretch) }; debug_assert!(stretch >= 0.); - NonNegative(Percentage(stretch)) + FontStretch(NonNegative(Percentage(stretch))) } pub fn set_font_style(&mut self, v: longhands::font_style::computed_value::T) { diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 0dca4a4c67e..69f95532c16 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -335,7 +335,7 @@ ${helpers.predefined_type("-x-text-zoom", use gecko_bindings::structs::{LookAndFeel_FontID, nsFont}; use std::mem; use values::computed::Percentage; - use values::computed::font::{FontSize, FontStyle, FontFamilyList}; + use values::computed::font::{FontSize, FontStretch, FontStyle, FontFamilyList}; use values::generics::NonNegative; let id = match *self { @@ -356,9 +356,9 @@ ${helpers.predefined_type("-x-text-zoom", ) } let font_weight = longhands::font_weight::computed_value::T::from_gecko_weight(system.weight); - let font_stretch = NonNegative(Percentage(unsafe { + let font_stretch = FontStretch(NonNegative(Percentage(unsafe { bindings::Gecko_FontStretch_ToFloat(system.stretch) - })); + }))); let font_style = FontStyle::from_gecko(system.style); let ret = ComputedSystemFont { font_family: longhands::font_family::computed_value::T(