servo: Merge #18527 - Revert "Measure ImageValue objects." (from mbrubeck:revert); r=mbrubeck
authorMatt Brubeck <mbrubeck@limpet.net>
Fri, 15 Sep 2017 12:44:23 -0700
changeset 665711 d0e83cfaff2ffa3512c4fb066ad4fbb3acb17eb7
parent 665710 867559d318f3d860fcb1c29608b58e1a1273be16
child 665712 aa02aa853d370a776efc59c699895a34a8671777
push id80148
push userbmo:emilio@crisal.io
push dateFri, 15 Sep 2017 20:59:22 +0000
reviewersmbrubeck
milestone57.0a1
servo: Merge #18527 - Revert "Measure ImageValue objects." (from mbrubeck:revert); r=mbrubeck This reverts commit a185393ceea46f1e61dfd7134b589b150d6e27c3 (#18515). Source-Repo: https://github.com/servo/servo Source-Revision: fb00fc222a1fd4c3c664f3d5dfbe5cacecb0c681
servo/components/style/gecko/generated/bindings.rs
servo/components/style/gecko/url.rs
--- a/servo/components/style/gecko/generated/bindings.rs
+++ b/servo/components/style/gecko/generated/bindings.rs
@@ -1000,20 +1000,16 @@ extern "C" {
     pub fn Gecko_ReleaseImageValueArbitraryThread(aPtr: *mut ImageValue);
 }
 extern "C" {
     pub fn Gecko_ImageValue_Create(aURI: ServoBundledURI,
                                    aURIString: ServoRawOffsetArc<RustString>)
      -> *mut ImageValue;
 }
 extern "C" {
-    pub fn Gecko_ImageValue_SizeOfIncludingThis(aImageValue: *mut ImageValue)
-     -> usize;
-}
-extern "C" {
     pub fn Gecko_SetLayerImageImageValue(image: *mut nsStyleImage,
                                          aImageValue: *mut ImageValue);
 }
 extern "C" {
     pub fn Gecko_SetImageElement(image: *mut nsStyleImage,
                                  atom: *mut nsIAtom);
 }
 extern "C" {
--- a/servo/components/style/gecko/url.rs
+++ b/servo/components/style/gecko/url.rs
@@ -4,37 +4,39 @@
 
 //! Common handling for the specified value CSS url() values.
 
 use gecko_bindings::structs::{ServoBundledURI, URLExtraData};
 use gecko_bindings::structs::mozilla::css::URLValueData;
 use gecko_bindings::structs::root::{nsStyleImageRequest, RustString};
 use gecko_bindings::structs::root::mozilla::css::ImageValue;
 use gecko_bindings::sugar::refptr::RefPtr;
-use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
 use parser::ParserContext;
 use servo_arc::{Arc, RawOffsetArc};
 use std::fmt;
 use std::mem;
 use style_traits::{ToCss, ParseError};
 
 /// A specified url() value for gecko. Gecko does not eagerly resolve SpecifiedUrls.
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
 pub struct SpecifiedUrl {
     /// The URL in unresolved string form.
     ///
     /// Refcounted since cloning this should be cheap and data: uris can be
     /// really large.
+    #[ignore_malloc_size_of = "XXX: do this once bug 1397971 lands"]
     serialization: Arc<String>,
 
     /// The URL extra data.
+    #[ignore_malloc_size_of = "RefPtr is tricky, and there aren't many of these in practise"]
     pub extra_data: RefPtr<URLExtraData>,
 
     /// Cache ImageValue, if any, so that we can reuse it while rematching a
     /// a property with this specified url value.
+    #[ignore_malloc_size_of = "XXX: do this once bug 1397971 lands"]
     pub image_value: Option<RefPtr<ImageValue>>,
 }
 trivial_to_computed_value!(SpecifiedUrl);
 
 impl SpecifiedUrl {
     /// Try to parse a URL from a string value that is a valid CSS token for a
     /// URL.
     ///
@@ -137,30 +139,8 @@ impl SpecifiedUrl {
 
 impl ToCss for SpecifiedUrl {
     fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
         dest.write_str("url(")?;
         self.serialization.to_css(dest)?;
         dest.write_str(")")
     }
 }
-
-impl MallocSizeOf for SpecifiedUrl {
-    fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
-        use gecko_bindings::bindings::Gecko_ImageValue_SizeOfIncludingThis;
-
-        let mut n = 0;
-
-        // XXX: measure `serialization` once bug 1397971 lands
-
-        // We ignore `extra_data`, because RefPtr is tricky, and there aren't
-        // many of them in practise (sharing is common).
-
-        if let Some(ref image_value) = self.image_value {
-            // Although this is a RefPtr, this is the primary reference because
-            // SpecifiedUrl is responsible for creating the image_value. So we
-            // measure unconditionally here.
-            n += unsafe { Gecko_ImageValue_SizeOfIncludingThis(image_value.clone().get()) };
-        }
-
-        n
-    }
-}