Bug 1540357 - Fix implicit int truncation in dom/canvas's dom/* includes. r=qdot
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 02 Apr 2019 17:00:45 +0000
changeset 467621 54a2f08bcf48725ae4de58481c61b07011601d90
parent 467620 89552599db42520b12be078b9db8f848cce87a36
child 467622 f4debce94b0003c8445be2eeae913790f6f65df1
push id35806
push userrgurzau@mozilla.com
push dateWed, 03 Apr 2019 04:07:39 +0000
treeherdermozilla-central@45808ab18609 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1540357
milestone68.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 1540357 - Fix implicit int truncation in dom/canvas's dom/* includes. r=qdot Depends on D25496 Differential Revision: https://phabricator.services.mozilla.com/D25497
dom/base/Selection.h
dom/media/AudioSampleFormat.h
dom/svg/SVGAnimatedPreserveAspectRatio.h
dom/svg/SVGPreserveAspectRatio.h
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -905,14 +905,15 @@ inline RawSelectionType ToRawSelectionTy
 inline RawSelectionType ToRawSelectionType(TextRangeType aTextRangeType) {
   return ToRawSelectionType(ToSelectionType(aTextRangeType));
 }
 
 inline SelectionTypeMask ToSelectionTypeMask(SelectionType aSelectionType) {
   MOZ_ASSERT(aSelectionType != SelectionType::eInvalid);
   return aSelectionType == SelectionType::eNone
              ? 0
-             : (1 << (static_cast<uint8_t>(aSelectionType) - 1));
+             : static_cast<SelectionTypeMask>(
+                   1 << (static_cast<uint8_t>(aSelectionType) - 1));
 }
 
 }  // namespace mozilla
 
 #endif  // mozilla_Selection_h__
--- a/dom/media/AudioSampleFormat.h
+++ b/dom/media/AudioSampleFormat.h
@@ -97,17 +97,17 @@ template <typename T>
 T UInt8bitToAudioSample(uint8_t aValue);
 
 template <>
 inline float UInt8bitToAudioSample<float>(uint8_t aValue) {
   return aValue * (static_cast<float>(2) / UINT8_MAX) - static_cast<float>(1);
 }
 template <>
 inline int16_t UInt8bitToAudioSample<int16_t>(uint8_t aValue) {
-  return (int16_t(aValue) << 8) + aValue + INT16_MIN;
+  return static_cast<int16_t>((aValue << 8) + aValue + INT16_MIN);
 }
 
 template <typename T>
 T IntegerToAudioSample(int16_t aValue);
 
 template <>
 inline float IntegerToAudioSample<float>(int16_t aValue) {
   return aValue / 32768.0f;
@@ -121,17 +121,17 @@ template <typename T>
 T Int24bitToAudioSample(int32_t aValue);
 
 template <>
 inline float Int24bitToAudioSample<float>(int32_t aValue) {
   return aValue / static_cast<float>(1 << 23);
 }
 template <>
 inline int16_t Int24bitToAudioSample<int16_t>(int32_t aValue) {
-  return aValue / 256;
+  return static_cast<int16_t>(aValue / 256);
 }
 
 template <typename SrcT, typename DstT>
 inline void ConvertAudioSample(SrcT aIn, DstT& aOut);
 
 template <>
 inline void ConvertAudioSample(int16_t aIn, int16_t& aOut) {
   aOut = aIn;
--- a/dom/svg/SVGAnimatedPreserveAspectRatio.h
+++ b/dom/svg/SVGAnimatedPreserveAspectRatio.h
@@ -41,27 +41,29 @@ class SVGAnimatedPreserveAspectRatio fin
   void GetBaseValueString(nsAString& aValue) const;
 
   void SetBaseValue(const SVGPreserveAspectRatio& aValue,
                     dom::SVGElement* aSVGElement);
   nsresult SetBaseAlign(uint16_t aAlign, dom::SVGElement* aSVGElement) {
     if (aAlign < SVG_ALIGN_MIN_VALID || aAlign > SVG_ALIGN_MAX_VALID) {
       return NS_ERROR_FAILURE;
     }
-    SetBaseValue(SVGPreserveAspectRatio(aAlign, mBaseVal.GetMeetOrSlice()),
+    SetBaseValue(SVGPreserveAspectRatio(static_cast<uint8_t>(aAlign),
+                                        mBaseVal.GetMeetOrSlice()),
                  aSVGElement);
     return NS_OK;
   }
   nsresult SetBaseMeetOrSlice(uint16_t aMeetOrSlice,
                               dom::SVGElement* aSVGElement) {
     if (aMeetOrSlice < SVG_MEETORSLICE_MIN_VALID ||
         aMeetOrSlice > SVG_MEETORSLICE_MAX_VALID) {
       return NS_ERROR_FAILURE;
     }
-    SetBaseValue(SVGPreserveAspectRatio(mBaseVal.GetAlign(), aMeetOrSlice),
+    SetBaseValue(SVGPreserveAspectRatio(mBaseVal.GetAlign(),
+                                        static_cast<uint8_t>(aMeetOrSlice)),
                  aSVGElement);
     return NS_OK;
   }
   void SetAnimValue(uint64_t aPackedValue, dom::SVGElement* aSVGElement);
 
   const SVGPreserveAspectRatio& GetBaseValue() const { return mBaseVal; }
   const SVGPreserveAspectRatio& GetAnimValue() const { return mAnimVal; }
   bool IsAnimated() const { return mIsAnimated; }
--- a/dom/svg/SVGPreserveAspectRatio.h
+++ b/dom/svg/SVGPreserveAspectRatio.h
@@ -38,43 +38,43 @@ class SVGPreserveAspectRatio final {
 
  public:
   explicit SVGPreserveAspectRatio()
       : mAlign(dom::SVGPreserveAspectRatio_Binding::
                    SVG_PRESERVEASPECTRATIO_UNKNOWN),
         mMeetOrSlice(
             dom::SVGPreserveAspectRatio_Binding::SVG_MEETORSLICE_UNKNOWN) {}
 
-  SVGPreserveAspectRatio(uint16_t aAlign, uint16_t aMeetOrSlice)
+  SVGPreserveAspectRatio(uint8_t aAlign, uint8_t aMeetOrSlice)
       : mAlign(aAlign), mMeetOrSlice(aMeetOrSlice) {}
 
   static nsresult FromString(const nsAString& aString,
                              SVGPreserveAspectRatio* aValue);
   void ToString(nsAString& aValueAsString) const;
 
   bool operator==(const SVGPreserveAspectRatio& aOther) const;
 
   nsresult SetAlign(uint16_t aAlign) {
     if (aAlign < SVG_ALIGN_MIN_VALID || aAlign > SVG_ALIGN_MAX_VALID)
       return NS_ERROR_FAILURE;
     mAlign = static_cast<uint8_t>(aAlign);
     return NS_OK;
   }
 
-  uint16_t GetAlign() const { return mAlign; }
+  auto GetAlign() const { return mAlign; }
 
   nsresult SetMeetOrSlice(uint16_t aMeetOrSlice) {
     if (aMeetOrSlice < SVG_MEETORSLICE_MIN_VALID ||
         aMeetOrSlice > SVG_MEETORSLICE_MAX_VALID)
       return NS_ERROR_FAILURE;
     mMeetOrSlice = static_cast<uint8_t>(aMeetOrSlice);
     return NS_OK;
   }
 
-  uint16_t GetMeetOrSlice() const { return mMeetOrSlice; }
+  auto GetMeetOrSlice() const { return mMeetOrSlice; }
 
   PLDHashNumber Hash() const { return HashGeneric(mAlign, mMeetOrSlice); }
 
  private:
   // We can't use enum types here because some compilers fail to pack them.
   uint8_t mAlign;
   uint8_t mMeetOrSlice;
 };