Bug 764299 (Part 1) - Add hashing to SVGImageContext. r=dholbert
authorSeth Fowler <seth@mozilla.com>
Tue, 22 Oct 2013 13:37:57 +0200
changeset 165479 e4d94de0a4ef91b1cf7705a2aa6e126beecb9d37
parent 165478 a9763f53d9e10380a8802fc44b580f3cb724a5fb
child 165480 59dd9491503a1312fb06185f63622e2ce970cca8
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs764299
milestone27.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 764299 (Part 1) - Add hashing to SVGImageContext. r=dholbert
content/svg/content/src/SVGPreserveAspectRatio.h
layout/svg/SVGImageContext.h
--- a/content/svg/content/src/SVGPreserveAspectRatio.h
+++ b/content/svg/content/src/SVGPreserveAspectRatio.h
@@ -1,15 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#pragma once
+#ifndef MOZILLA_CONTENT_SVGPRESERVEASPECTRATIO_H_
+#define MOZILLA_CONTENT_SVGPRESERVEASPECTRATIO_H_
 
+#include "mozilla/HashFunctions.h"  // for HashGeneric
 #include "mozilla/TypedEnum.h"
 
 #include "nsWrapperCache.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "mozilla/ErrorResult.h"
 #include "nsSVGElement.h"
 
@@ -93,16 +95,20 @@ public:
   void SetDefer(bool aDefer) {
     mDefer = aDefer;
   }
 
   bool GetDefer() const {
     return mDefer;
   }
 
+  uint32_t Hash() const {
+    return HashGeneric(mAlign, mMeetOrSlice, mDefer);
+  }
+
 private:
   // We can't use enum types here because some compilers fail to pack them.
   uint8_t mAlign;
   uint8_t mMeetOrSlice;
   bool mDefer;
 };
 
 namespace dom {
@@ -136,8 +142,10 @@ public:
 protected:
   SVGAnimatedPreserveAspectRatio* mVal; // kept alive because it belongs to mSVGElement
   nsRefPtr<nsSVGElement> mSVGElement;
   const bool mIsBaseValue;
 };
 
 } //namespace dom
 } //namespace mozilla
+
+#endif // MOZILLA_CONTENT_SVGPRESERVEASPECTRATIO_H_
--- a/layout/svg/SVGImageContext.h
+++ b/layout/svg/SVGImageContext.h
@@ -11,31 +11,37 @@
 namespace mozilla {
 
 // SVG image-specific rendering context. For imgIContainer::Draw.
 // Used to pass information about overridden attributes from an SVG <image>
 // element to the image's internal SVG document when it's drawn.
 class SVGImageContext
 {
 public:
+  SVGImageContext() { }
+
   SVGImageContext(SVGPreserveAspectRatio aPreserveAspectRatio)
     : mPreserveAspectRatio(aPreserveAspectRatio)
   { }
 
   const SVGPreserveAspectRatio& GetPreserveAspectRatio() const {
     return mPreserveAspectRatio;
   }
 
   bool operator==(const SVGImageContext& aOther) const {
     return mPreserveAspectRatio == aOther.mPreserveAspectRatio;
   }
 
   bool operator!=(const SVGImageContext& aOther) const {
     return !(*this == aOther);
   }
 
+  uint32_t Hash() const {
+    return mPreserveAspectRatio.Hash();
+  }
+
 private:
-  const SVGPreserveAspectRatio mPreserveAspectRatio;
+  SVGPreserveAspectRatio mPreserveAspectRatio;
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGCONTEXT_H_