From 07df897bae414296f012d63d149268c8d7c65829 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 16 May 2018 14:01:25 +1000 Subject: [PATCH] Bug 1461858 part 3 - Have from_image_request reuse ImageValue from image request directly. r=emilio And also remove ComputedImageUrl::from_url_value_data. MozReview-Commit-ID: 5zifQlU7tOz --HG-- extra : rebase_source : 23631ad2e9144cf30951a3d07421a8e5ae0ba8ec --- layout/style/ServoBindings.cpp | 8 ++++---- layout/style/ServoBindings.h | 2 +- servo/components/style/gecko/conversions.rs | 7 ++++--- servo/components/style/gecko/url.rs | 14 +++----------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index 91802128d4f3..e59a42c739c9 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -1668,11 +1668,11 @@ Gecko_CreateGradient(uint8_t aShape, return result; } -const mozilla::css::URLValueData* -Gecko_GetURLValue(const nsStyleImage* aImage) +const nsStyleImageRequest* +Gecko_GetImageRequest(const nsStyleImage* aImage) { - MOZ_ASSERT(aImage && aImage->GetType() == eStyleImageType_Image); - return aImage->GetURLValue(); + MOZ_ASSERT(aImage); + return aImage->GetImageRequest(); } nsAtom* diff --git a/layout/style/ServoBindings.h b/layout/style/ServoBindings.h index 5e45ecc08af0..aa6caaaeb201 100644 --- a/layout/style/ServoBindings.h +++ b/layout/style/ServoBindings.h @@ -371,7 +371,7 @@ nsStyleGradient* Gecko_CreateGradient(uint8_t shape, bool moz_legacy_syntax, uint32_t stops); -const mozilla::css::URLValueData* Gecko_GetURLValue(const nsStyleImage* image); +const nsStyleImageRequest* Gecko_GetImageRequest(const nsStyleImage* image); nsAtom* Gecko_GetImageElement(const nsStyleImage* image); const nsStyleGradient* Gecko_GetGradientImageValue(const nsStyleImage* image); diff --git a/servo/components/style/gecko/conversions.rs b/servo/components/style/gecko/conversions.rs index 76faf2a44bab..bb0ea1e50131 100644 --- a/servo/components/style/gecko/conversions.rs +++ b/servo/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/servo/components/style/gecko/url.rs b/servo/components/style/gecko/url.rs index 102f59dad9c7..163c16905232 100644 --- a/servo/components/style/gecko/url.rs +++ b/servo/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 }) } }