Bug 1357754 - Add ScrollDirection IPC serialization code. r=botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 20 Apr 2017 10:04:49 -0400
changeset 565811 b407a61a019fb665c309c9b40fc8e2945157161a
parent 565810 5e15a2ac61f5cdff8a1e3e55f18e4eeb14ca3c12
child 565812 ab360eb919545287ce817359d373f2a55042efd0
push id55024
push userkgupta@mozilla.com
push dateThu, 20 Apr 2017 14:05:27 +0000
reviewersbotond
bugs1357754
milestone55.0a1
Bug 1357754 - Add ScrollDirection IPC serialization code. r=botond In the next patch we'll need to send ScrollDirection over IPDL so we need to add serialization code for it. MozReview-Commit-ID: HK8ibuhhnkS
gfx/ipc/GfxMessageUtils.h
gfx/layers/LayersTypes.h
gfx/layers/apz/test/gtest/APZTestCommon.h
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -290,16 +290,24 @@ struct ParamTraits<mozilla::layers::Text
 
 template <>
 struct ParamTraits<mozilla::layers::DiagnosticTypes>
   : public BitFlagsEnumSerializer<
              mozilla::layers::DiagnosticTypes,
              mozilla::layers::DiagnosticTypes::ALL_BITS>
 {};
 
+template <>
+struct ParamTraits<mozilla::layers::ScrollDirection>
+  : public ContiguousEnumSerializer<
+            mozilla::layers::ScrollDirection,
+            mozilla::layers::ScrollDirection::NONE,
+            mozilla::layers::ScrollDirection::SENTINEL>
+{};
+
 /*
 template <>
 struct ParamTraits<mozilla::PixelFormat>
   : public EnumSerializer<mozilla::PixelFormat,
                           SurfaceFormat::A8R8G8B8_UINT32,
                           SurfaceFormat::UNKNOWN>
 {};
 */
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -297,15 +297,16 @@ public:
   }
 private:
   uint64_t mHandle;
 };
 
 enum class ScrollDirection : uint32_t {
   NONE,
   VERTICAL,
-  HORIZONTAL
+  HORIZONTAL,
+  SENTINEL /* for IPC serialization */
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* GFX_LAYERSTYPES_H */
--- a/gfx/layers/apz/test/gtest/APZTestCommon.h
+++ b/gfx/layers/apz/test/gtest/APZTestCommon.h
@@ -263,16 +263,19 @@ public:
       EXPECT_EQ(PANNING, mState);
       break;
     case ScrollDirection::HORIZONTAL:
       EXPECT_EQ(PANNING_LOCKED_X, mState);
       break;
     case ScrollDirection::VERTICAL:
       EXPECT_EQ(PANNING_LOCKED_Y, mState);
       break;
+    case ScrollDirection::SENTINEL:
+      MOZ_ASSERT(false, "Invalid value");
+      break;
     }
   }
 
   void AdvanceAnimationsUntilEnd(const TimeDuration& aIncrement = TimeDuration::FromMilliseconds(10)) {
     while (AdvanceAnimations(mcc->Time())) {
       mcc->AdvanceBy(aIncrement);
     }
   }