Bug 1118926 (Part 1) - Remove remnants of -moz-resolution in C++ code. r=tn
authorSeth Fowler <mark.seth.fowler@gmail.com>
Wed, 30 Sep 2015 17:00:52 -0700
changeset 265445 d177c3dbbd154651b738bef519629cc75377dbe4
parent 265444 d7ba52bbc272d5207768e2c9adef6ed863d5bfa1
child 265446 f82ed42b855dfd2e87508134fbc84d9bc22ebce5
push id29462
push usercbook@mozilla.com
push dateThu, 01 Oct 2015 10:39:47 +0000
treeherdermozilla-central@2c1fb007137d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1118926
milestone44.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 1118926 (Part 1) - Remove remnants of -moz-resolution in C++ code. r=tn
image/Decoder.h
image/DecoderFactory.cpp
image/DecoderFactory.h
image/ImageCacheKey.cpp
image/ImageFactory.cpp
image/RasterImage.cpp
image/RasterImage.h
netwerk/base/nsMediaFragmentURIParser.cpp
netwerk/base/nsMediaFragmentURIParser.h
toolkit/components/places/nsFaviconService.cpp
--- a/image/Decoder.h
+++ b/image/Decoder.h
@@ -126,24 +126,16 @@ public:
    * Set the requested sample size for this decoder. Used to implement the
    * -moz-sample-size media fragment.
    *
    *  XXX(seth): Support for -moz-sample-size will be removed in bug 1120056.
    */
   virtual void SetSampleSize(int aSampleSize) { }
 
   /**
-   * Set the requested resolution for this decoder. Used to implement the
-   * -moz-resolution media fragment.
-   *
-   *  XXX(seth): Support for -moz-resolution will be removed in bug 1118926.
-   */
-  virtual void SetResolution(const gfx::IntSize& aResolution) { }
-
-  /**
    * Set an iterator to the SourceBuffer which will feed data to this decoder.
    *
    * This should be called for almost all decoders; the exceptions are the
    * contained decoders of an nsICODecoder, which will be fed manually via Write
    * instead.
    *
    * This must be called before Init() is called.
    */
--- a/image/DecoderFactory.cpp
+++ b/image/DecoderFactory.cpp
@@ -106,34 +106,32 @@ DecoderFactory::GetDecoder(DecoderType a
 
 /* static */ already_AddRefed<Decoder>
 DecoderFactory::CreateDecoder(DecoderType aType,
                               RasterImage* aImage,
                               SourceBuffer* aSourceBuffer,
                               const Maybe<IntSize>& aTargetSize,
                               DecoderFlags aDecoderFlags,
                               SurfaceFlags aSurfaceFlags,
-                              int aSampleSize,
-                              const IntSize& aResolution)
+                              int aSampleSize)
 {
   if (aType == DecoderType::UNKNOWN) {
     return nullptr;
   }
 
   nsRefPtr<Decoder> decoder =
     GetDecoder(aType, aImage, bool(aDecoderFlags & DecoderFlags::IS_REDECODE));
   MOZ_ASSERT(decoder, "Should have a decoder now");
 
   // Initialize the decoder.
   decoder->SetMetadataDecode(false);
   decoder->SetIterator(aSourceBuffer->Iterator());
   decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::FIRST_FRAME_ONLY);
   decoder->SetSurfaceFlags(aSurfaceFlags);
   decoder->SetSampleSize(aSampleSize);
-  decoder->SetResolution(aResolution);
 
   // Set a target size for downscale-during-decode if applicable.
   if (aTargetSize) {
     DebugOnly<nsresult> rv = decoder->SetTargetSize(*aTargetSize);
     MOZ_ASSERT(NS_SUCCEEDED(rv), "Bad downscale-during-decode target size?");
   }
 
   decoder->Init();
@@ -144,18 +142,17 @@ DecoderFactory::CreateDecoder(DecoderTyp
   return decoder.forget();
 }
 
 /* static */ already_AddRefed<Decoder>
 DecoderFactory::CreateAnimationDecoder(DecoderType aType,
                                        RasterImage* aImage,
                                        SourceBuffer* aSourceBuffer,
                                        DecoderFlags aDecoderFlags,
-                                       SurfaceFlags aSurfaceFlags,
-                                       const IntSize& aResolution)
+                                       SurfaceFlags aSurfaceFlags)
 {
   if (aType == DecoderType::UNKNOWN) {
     return nullptr;
   }
 
   MOZ_ASSERT(aType == DecoderType::GIF || aType == DecoderType::PNG,
              "Calling CreateAnimationDecoder for non-animating DecoderType");
 
@@ -163,46 +160,43 @@ DecoderFactory::CreateAnimationDecoder(D
     GetDecoder(aType, aImage, /* aIsRedecode = */ true);
   MOZ_ASSERT(decoder, "Should have a decoder now");
 
   // Initialize the decoder.
   decoder->SetMetadataDecode(false);
   decoder->SetIterator(aSourceBuffer->Iterator());
   decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::IS_REDECODE);
   decoder->SetSurfaceFlags(aSurfaceFlags);
-  decoder->SetResolution(aResolution);
 
   decoder->Init();
   if (NS_FAILED(decoder->GetDecoderError())) {
     return nullptr;
   }
 
   return decoder.forget();
 }
 
 /* static */ already_AddRefed<Decoder>
 DecoderFactory::CreateMetadataDecoder(DecoderType aType,
                                       RasterImage* aImage,
                                       SourceBuffer* aSourceBuffer,
-                                      int aSampleSize,
-                                      const IntSize& aResolution)
+                                      int aSampleSize)
 {
   if (aType == DecoderType::UNKNOWN) {
     return nullptr;
   }
 
   nsRefPtr<Decoder> decoder =
     GetDecoder(aType, aImage, /* aIsRedecode = */ false);
   MOZ_ASSERT(decoder, "Should have a decoder now");
 
   // Initialize the decoder.
   decoder->SetMetadataDecode(true);
   decoder->SetIterator(aSourceBuffer->Iterator());
   decoder->SetSampleSize(aSampleSize);
-  decoder->SetResolution(aResolution);
 
   decoder->Init();
   if (NS_FAILED(decoder->GetDecoderError())) {
     return nullptr;
   }
 
   return decoder.forget();
 }
--- a/image/DecoderFactory.h
+++ b/image/DecoderFactory.h
@@ -58,74 +58,65 @@ public:
    *                    be scaled to during decoding. It's an error to specify
    *                    a target size for a decoder type which doesn't support
    *                    downscale-during-decode.
    * @param aDecoderFlags Flags specifying the behavior of this decoder.
    * @param aSurfaceFlags Flags specifying the type of output this decoder
    *                      should produce.
    * @param aSampleSize The sample size requested using #-moz-samplesize (or 0
    *                    if none).
-   * @param aResolution The resolution requested using #-moz-resolution (or an
-   *                    empty rect if none).
    */
   static already_AddRefed<Decoder>
   CreateDecoder(DecoderType aType,
                 RasterImage* aImage,
                 SourceBuffer* aSourceBuffer,
                 const Maybe<gfx::IntSize>& aTargetSize,
                 DecoderFlags aDecoderFlags,
                 SurfaceFlags aSurfaceFlags,
-                int aSampleSize,
-                const gfx::IntSize& aResolution);
+                int aSampleSize);
 
   /**
    * Creates and initializes a decoder for animated images of type @aType.
    * The decoder will send notifications to @aImage.
    *
    * @param aType Which type of decoder to create - JPEG, PNG, etc.
    * @param aImage The image will own the decoder and which should receive
    *               notifications as decoding progresses.
    * @param aSourceBuffer The SourceBuffer which the decoder will read its data
    *                      from.
    * @param aDecoderFlags Flags specifying the behavior of this decoder.
    * @param aSurfaceFlags Flags specifying the type of output this decoder
    *                      should produce.
-   * @param aResolution The resolution requested using #-moz-resolution (or an
-   *                    empty rect if none).
    */
   static already_AddRefed<Decoder>
   CreateAnimationDecoder(DecoderType aType,
                          RasterImage* aImage,
                          SourceBuffer* aSourceBuffer,
                          DecoderFlags aDecoderFlags,
-                         SurfaceFlags aSurfaceFlags,
-                         const gfx::IntSize& aResolution);
+                         SurfaceFlags aSurfaceFlags);
 
   /**
    * Creates and initializes a metadata decoder of type @aType. This decoder
    * will only decode the image's header, extracting metadata like the size of
    * the image. No actual image data will be decoded and no surfaces will be
    * allocated. The decoder will send notifications to @aImage.
    *
    * @param aType Which type of decoder to create - JPEG, PNG, etc.
    * @param aImage The image will own the decoder and which should receive
    *               notifications as decoding progresses.
    * @param aSourceBuffer The SourceBuffer which the decoder will read its data
    *                      from.
    * @param aSampleSize The sample size requested using #-moz-samplesize (or 0
    *                    if none).
-   * @param aResolution The resolution requested using #-moz-resolution (or an
-   *                    empty rect if none).
    */
   static already_AddRefed<Decoder>
   CreateMetadataDecoder(DecoderType aType,
                         RasterImage* aImage,
                         SourceBuffer* aSourceBuffer,
-                        int aSampleSize,
-                        const gfx::IntSize& aResolution);
+                        int aSampleSize);
 
   /**
    * Creates and initializes an anonymous decoder (one which isn't associated
    * with an Image object). Only the first frame of the image will be decoded.
    *
    * @param aType Which type of decoder to create - JPEG, PNG, etc.
    * @param aSourceBuffer The SourceBuffer which the decoder will read its data
    *                      from.
--- a/image/ImageCacheKey.cpp
+++ b/image/ImageCacheKey.cpp
@@ -107,19 +107,19 @@ ImageCacheKey::ComputeHash(ImageURL* aUR
                            const Maybe<uint64_t>& aBlobSerial)
 {
   // Since we frequently call Hash() several times in a row on the same
   // ImageCacheKey, as an optimization we compute our hash once and store it.
 
   if (aBlobSerial) {
     // For blob URIs, we hash the serial number of the underlying blob, so that
     // different blob URIs which point to the same blob share a cache entry. We
-    // also include the ref portion of the URI to support -moz-samplesize and
-    // -moz-resolution, which require us to create different Image objects even
-    // if the source data is the same.
+    // also include the ref portion of the URI to support -moz-samplesize, which
+    // requires us to create different Image objects even if the source data is
+    // the same.
     nsAutoCString ref;
     aURI->GetRef(ref);
     return HashGeneric(*aBlobSerial, HashString(ref));
   }
 
   // For non-blob URIs, we hash the URI spec.
   nsAutoCString spec;
   aURI->GetSpec(spec);
--- a/image/ImageFactory.cpp
+++ b/image/ImageFactory.cpp
@@ -203,20 +203,16 @@ ImageFactory::CreateRasterImage(nsIReque
 
   nsRefPtr<RasterImage> newImage = new RasterImage(aURI);
   aProgressTracker->SetImage(newImage);
   newImage->SetProgressTracker(aProgressTracker);
 
   nsAutoCString ref;
   aURI->GetRef(ref);
   net::nsMediaFragmentURIParser parser(ref);
-  if (parser.HasResolution()) {
-    newImage->SetRequestedResolution(parser.GetResolution());
-  }
-
   if (parser.HasSampleSize()) {
       /* Get our principal */
       nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
       nsCOMPtr<nsIPrincipal> principal;
       if (chan) {
         nsContentUtils::GetSecurityManager()
           ->GetChannelResultPrincipal(chan, getter_AddRefs(principal));
       }
--- a/image/RasterImage.cpp
+++ b/image/RasterImage.cpp
@@ -1285,24 +1285,22 @@ RasterImage::Decode(const IntSize& aSize
     decoderFlags |= DecoderFlags::IS_REDECODE;
   }
 
   // Create a decoder.
   nsRefPtr<Decoder> decoder;
   if (mAnim) {
     decoder = DecoderFactory::CreateAnimationDecoder(mDecoderType, this,
                                                      mSourceBuffer, decoderFlags,
-                                                     ToSurfaceFlags(aFlags),
-                                                     mRequestedResolution);
+                                                     ToSurfaceFlags(aFlags));
   } else {
     decoder = DecoderFactory::CreateDecoder(mDecoderType, this, mSourceBuffer,
                                             targetSize, decoderFlags,
                                             ToSurfaceFlags(aFlags),
-                                            mRequestedSampleSize,
-                                            mRequestedResolution);
+                                            mRequestedSampleSize);
   }
 
   // Make sure DecoderFactory was able to create a decoder successfully.
   if (!decoder) {
     return NS_ERROR_FAILURE;
   }
 
   // Add a placeholder for the first frame to the SurfaceCache so we won't
@@ -1347,18 +1345,17 @@ RasterImage::DecodeMetadata(uint32_t aFl
     return NS_ERROR_FAILURE;
   }
 
   MOZ_ASSERT(!mHasSize, "Should not do unnecessary metadata decodes");
 
   // Create a decoder.
   nsRefPtr<Decoder> decoder =
     DecoderFactory::CreateMetadataDecoder(mDecoderType, this, mSourceBuffer,
-                                          mRequestedSampleSize,
-                                          mRequestedResolution);
+                                          mRequestedSampleSize);
 
   // Make sure DecoderFactory was able to create a decoder successfully.
   if (!decoder) {
     return NS_ERROR_FAILURE;
   }
 
   // We're ready to decode; start the decoder.
   LaunchDecoder(decoder, this, aFlags, mHasSourceData);
--- a/image/RasterImage.h
+++ b/image/RasterImage.h
@@ -228,21 +228,16 @@ public:
    * We take this approach rather than having the source data management code do
    * something more complicated (like chunklisting) because HTTP is by far the
    * dominant source of images, and the Content-Length header is quite reliable.
    * Thus, pre-allocation simplifies code and reduces the total number of
    * allocations.
    */
   nsresult SetSourceSizeHint(uint32_t aSizeHint);
 
-  /* Provide a hint for the requested resolution of the resulting image. */
-  void SetRequestedResolution(const nsIntSize requestedResolution) {
-    mRequestedResolution = requestedResolution;
-  }
-
   /* Provide a hint for the requested dimension of the resulting image. */
   void SetRequestedSampleSize(int requestedSampleSize) {
     mRequestedSampleSize = requestedSampleSize;
   }
 
  nsCString GetURIString() {
     nsCString spec;
     if (GetURI()) {
@@ -360,20 +355,16 @@ private: // data
 
   // The type of decoder this image needs. Computed from the MIME type in Init().
   DecoderType                mDecoderType;
 
   // How many times we've decoded this image.
   // This is currently only used for statistics
   int32_t                        mDecodeCount;
 
-  // If the image contains multiple resolutions, a hint as to which one
-  // should be used
-  nsIntSize                  mRequestedResolution;
-
   // A hint for image decoder that directly scale the image to smaller buffer
   int                        mRequestedSampleSize;
 
   // A weak pointer to our ImageContainer, which stays alive only as long as
   // the layer system needs it.
   WeakPtr<layers::ImageContainer> mImageContainer;
 
   // If mImageContainer is non-null, this contains the DrawResult we obtained
--- a/netwerk/base/nsMediaFragmentURIParser.cpp
+++ b/netwerk/base/nsMediaFragmentURIParser.cpp
@@ -330,32 +330,16 @@ bool nsMediaFragmentURIParser::ParseXYWH
     mClip.emplace(x, y, w, h);
     mClipUnit = clipUnit;
     return true;
   }
 
   return false;
 }
 
-bool nsMediaFragmentURIParser::ParseMozResolution(nsDependentSubstring aString)
-{
-  int32_t w, h;
-
-  // Read and validate coordinates.
-  if (ParseInteger(aString, w) && w >= 0 &&
-      ParseCommaSeparator(aString)       &&
-      ParseInteger(aString, h) && h >= 0 &&
-      aString.Length() == 0) {
-    mResolution.emplace(w,h);
-    return true;
-  }
-
-  return false;
-}
-
 bool nsMediaFragmentURIParser::ParseMozSampleSize(nsDependentSubstring aString)
 {
   int32_t sampleSize;
 
   // Read and validate coordinates.
   if (ParseInteger(aString, sampleSize) && sampleSize > 0) {
     mSampleSize.emplace(sampleSize);
     return true;
@@ -379,31 +363,27 @@ void nsMediaFragmentURIParser::Parse(nsA
       NS_UnescapeURL(StringHead(nv, index), esc_Ref | esc_AlwaysCopy, name);
       NS_UnescapeURL(Substring(nv, index + 1, nv.Length()),
                      esc_Ref | esc_AlwaysCopy, value);
       fragments.AppendElement(make_pair(name, value));
     }
   }
 
   // Parse the media fragment values.
-  bool gotTemporal = false, gotSpatial = false,
-      gotResolution = false, gotSampleSize = false;
+  bool gotTemporal = false, gotSpatial = false, gotSampleSize = false;
   for (int i = fragments.Length() - 1 ; i >= 0 ; --i) {
-    if (gotTemporal && gotSpatial && gotResolution && gotSampleSize) {
+    if (gotTemporal && gotSpatial && gotSampleSize) {
       // We've got one of each possible type. No need to look at the rest.
       break;
     } else if (!gotTemporal && fragments[i].first.EqualsLiteral("t")) {
       nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
       gotTemporal = ParseNPT(nsDependentSubstring(value, 0));
     } else if (!gotSpatial && fragments[i].first.EqualsLiteral("xywh")) {
       nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
       gotSpatial = ParseXYWH(nsDependentSubstring(value, 0));
-    } else if (!gotResolution && fragments[i].first.EqualsLiteral("-moz-resolution")) {
-      nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
-      gotResolution = ParseMozResolution(nsDependentSubstring(value, 0));
     } else if (!gotSampleSize && fragments[i].first.EqualsLiteral("-moz-samplesize")) {
       nsAutoString value = NS_ConvertUTF8toUTF16(fragments[i].second);
       gotSampleSize = ParseMozSampleSize(nsDependentSubstring(value, 0));
     }
   }
 }
 
 } // namespace net
--- a/netwerk/base/nsMediaFragmentURIParser.h
+++ b/netwerk/base/nsMediaFragmentURIParser.h
@@ -50,22 +50,16 @@ public:
 
   // If a valid temporal media fragment indicated an end time, returns
   // it in units of seconds. If not, defaults to -1.
   double GetEndTime() const { return *mEnd; }
 
   // True if a valid spatial media fragment indicated a clipping region.
   bool HasClip() const { return mClip.isSome(); }
 
-  // True if a valid spatial media fragment indicated a resolution.
-  bool HasResolution() const { return mResolution.isSome(); }
-
-  // True if a valid spatial media fragment indicated a resolution.
-  nsIntSize GetResolution() const { return *mResolution; }
-
   // If a valid spatial media fragment indicated a clipping region,
   // returns the region. If not, returns an empty region. The unit
   // used depends on the value returned by GetClipUnit().
   nsIntRect GetClip() const { return *mClip; }
 
   // If a valid spatial media fragment indicated a clipping region,
   // returns the unit used.
   ClipUnit GetClipUnit() const { return mClipUnit; }
@@ -98,16 +92,15 @@ private:
   bool ParseMozResolution(nsDependentSubstring aString);
   bool ParseMozSampleSize(nsDependentSubstring aString);
 
   // Media fragment information.
   Maybe<double>    mStart;
   Maybe<double>    mEnd;
   Maybe<nsIntRect> mClip;
   ClipUnit         mClipUnit;
-  Maybe<nsIntSize> mResolution;
   Maybe<int>       mSampleSize;
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif
--- a/toolkit/components/places/nsFaviconService.cpp
+++ b/toolkit/components/places/nsFaviconService.cpp
@@ -579,17 +579,17 @@ nsFaviconService::GetFaviconDataAsync(ns
 {
   NS_ASSERTION(aCallback, "Doesn't make sense to call this without a callback");
   nsCOMPtr<mozIStorageAsyncStatement> stmt = mDB->GetAsyncStatement(
     "SELECT f.data, f.mime_type FROM moz_favicons f WHERE url = :icon_url"
   );
   NS_ENSURE_STATE(stmt);
 
   // Ignore the ref part of the URI before querying the database because
-  // we may have added the #-moz-resolution ref for rendering purposes.
+  // we may have added a media fragment for rendering purposes.
 
   nsAutoCString faviconURI;
   aFaviconURI->GetSpecIgnoringRef(faviconURI);
   nsresult rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("icon_url"), faviconURI);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<mozIStoragePendingStatement> pendingStatement;
   return stmt->ExecuteAsync(aCallback, getter_AddRefs(pendingStatement));