Bug 1461858 part 3 - Have from_image_request reuse ImageValue from image request directly. r=emilio
authorXidorn Quan <me@upsuper.org>
Wed, 16 May 2018 14:01:25 +1000
changeset 472699 ae886b67a96f86908bf670f09f689a6ca522bcf6
parent 472698 c728ab64fa12b8f4c84bbeea304da7351e6e6e97
child 472700 2e6a54985ec6b8c84d07173ec59dad6a7e49e209
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1461858
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
servo/components/style/gecko/conversions.rs
servo/components/style/gecko/url.rs
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1663,21 +1663,21 @@ Gecko_CreateGradient(uint8_t aShape,
 
   for (uint32_t i = 0; i < aStopCount; i++) {
     result->mStops.AppendElement(dummyStop);
   }
 
   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*
 Gecko_GetImageElement(const nsStyleImage* aImage)
 {
   MOZ_ASSERT(aImage && aImage->GetType() == eStyleImageType_Element);
   return const_cast<nsAtom*>(aImage->GetElementId());
 }
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -366,17 +366,17 @@ void Gecko_InitializeImageCropRect(nsSty
 
 nsStyleGradient* Gecko_CreateGradient(uint8_t shape,
                                       uint8_t size,
                                       bool repeating,
                                       bool legacy_syntax,
                                       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);
 
 // list-style-image style.
 void Gecko_SetListStyleImageNone(nsStyleList* style_struct);
 void Gecko_SetListStyleImageImageValue(nsStyleList* style_struct,
                                   mozilla::css::ImageValue* aImageValue);
 void Gecko_CopyListStyleImageFrom(nsStyleList* dest, const nsStyleList* src);
--- a/servo/components/style/gecko/conversions.rs
+++ b/servo/components/style/gecko/conversions.rs
@@ -421,19 +421,20 @@ impl nsStyleImage {
                 use gecko_string_cache::Atom;
                 let atom = bindings::Gecko_GetImageElement(self);
                 Some(GenericImage::Element(Atom::from_raw(atom)))
             },
             _ => panic!("Unexpected image type"),
         }
     }
 
-    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<Gradient> {
         use gecko::values::convert_nscolor_to_rgba;
         use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_CORNER as CLOSEST_CORNER;
         use self::structs::NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE as CLOSEST_SIDE;
         use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER as FARTHEST_CORNER;
         use self::structs::NS_STYLE_GRADIENT_SIZE_FARTHEST_SIDE as FARTHEST_SIDE;
--- a/servo/components/style/gecko/url.rs
+++ b/servo/components/style/gecko/url.rs
@@ -304,23 +304,15 @@ impl ToCss for ComputedImageUrl {
     where
         W: Write
     {
         serialize_computed_url(&self.0.image_value._base, dest)
     }
 }
 
 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 })
     }
 }