Bug 1510513 - Retain the formatting of MOZ_DEFINE_ENUM_* macros r=sylvestre
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 28 Nov 2018 09:14:19 +0000
changeset 507696 628d20bae43fbdfcf6ec3cee2c34cf3dd42626a6
parent 507695 7bebcd679d58f09ef3c7e77026d42f82a6467f01
child 507697 b4662b6db1b34414494d070e33481193625403d1
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssylvestre
bugs1510513
milestone65.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 1510513 - Retain the formatting of MOZ_DEFINE_ENUM_* macros r=sylvestre These macros tend to be handled quite poorly since the clang-format tokenizer cannot figure out how to handle them. Differential Revision: https://phabricator.services.mozilla.com/D13179
gfx/layers/FrameMetrics.h
gfx/layers/LayersTypes.h
gfx/layers/RepaintRequest.h
gfx/layers/apz/public/GeckoContentController.h
gfx/layers/apz/src/APZUtils.h
gfx/layers/apz/src/CheckerboardEvent.h
gfx/layers/apz/src/KeyboardScrollAction.h
js/xpconnect/src/xpcprivate.h
mfbt/tests/TestDefineEnum.cpp
toolkit/recordreplay/ipc/JSControl.h
widget/InputData.h
--- a/gfx/layers/FrameMetrics.h
+++ b/gfx/layers/FrameMetrics.h
@@ -49,28 +49,31 @@ struct ScrollUpdateInfo {
  * useful for shadow layers, because the metrics values are updated
  * atomically with new pixels.
  */
 struct FrameMetrics {
   friend struct IPC::ParamTraits<mozilla::layers::FrameMetrics>;
 
   typedef ScrollableLayerGuid::ViewID ViewID;
 public:
+  // clang-format off
   MOZ_DEFINE_ENUM_WITH_BASE_AT_CLASS_SCOPE(
     ScrollOffsetUpdateType, uint8_t, (
       eNone,          // The default; the scroll offset was not updated
       eMainThread,    // The scroll offset was updated by the main thread.
-      ePending,       // The scroll offset was updated on the main thread, but not
-                      // painted, so the layer texture data is still at the old
-                      // offset.
-      eRestore        // The scroll offset was updated by the main thread, but as
-                      // a restore from history or after a frame reconstruction.
-                      // In this case, APZ can ignore the offset change if the
-                      // user has done an APZ scroll already.
+      ePending,       // The scroll offset was updated on the main thread, but
+                      // not painted, so the layer texture data is still at the
+                      // old offset.
+      eRestore        // The scroll offset was updated by the main thread, but
+                      // as a restore from history or after a frame
+                      // reconstruction.  In this case, APZ can ignore the
+                      // offset change if the user has done an APZ scroll
+                      // already.
   ));
+  // clang-format on
 
   FrameMetrics()
     : mScrollId(ScrollableLayerGuid::NULL_SCROLL_ID)
     , mPresShellResolution(1)
     , mCompositionBounds(0, 0, 0, 0)
     , mDisplayPort(0, 0, 0, 0)
     , mCriticalDisplayPort(0, 0, 0, 0)
     , mScrollableRect(0, 0, 0, 0)
@@ -833,22 +836,24 @@ struct ScrollSnapInfo {
   // shipping the raw nsStyleCoord::CalcValue over IPC).
   nsPoint mScrollSnapDestination;
 
   // The scroll-snap-coordinates of any descendant frames of the scroll frame,
   // relative to the origin of the scrolled frame.
   nsTArray<nsPoint> mScrollSnapCoordinates;
 };
 
+// clang-format off
 MOZ_DEFINE_ENUM_CLASS_WITH_BASE(
   OverscrollBehavior, uint8_t, (
     Auto,
     Contain,
     None
 ));
+// clang-format on
 
 struct OverscrollBehaviorInfo {
   OverscrollBehaviorInfo()
     : mBehaviorX(OverscrollBehavior::Auto)
     , mBehaviorY(OverscrollBehavior::Auto)
   {}
 
   // Construct from StyleOverscrollBehavior values.
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -190,22 +190,24 @@ enum class DrawRegionClip : int8_t {
 
 enum class SurfaceMode : int8_t {
   SURFACE_NONE = 0,
   SURFACE_OPAQUE,
   SURFACE_SINGLE_CHANNEL_ALPHA,
   SURFACE_COMPONENT_ALPHA
 };
 
+// clang-format off
 MOZ_DEFINE_ENUM_CLASS_WITH_BASE(
   ScaleMode, int8_t, (
     SCALE_NONE,
     STRETCH
 // Unimplemented - PRESERVE_ASPECT_RATIO_CONTAIN
 ));
+// clang-format on
 
 struct EventRegions {
   // The hit region for a layer contains all areas on the layer that are
   // sensitive to events. This region is an over-approximation and may
   // contain regions that are not actually sensitive, but any such regions
   // will be included in the mDispatchToContentHitRegion.
   nsIntRegion mHitRegion;
   // The mDispatchToContentHitRegion for a layer contains all areas for
@@ -451,17 +453,19 @@ public:
   }
   uint64_t Value() const {
     return mHandle;
   }
 private:
   uint64_t mHandle;
 };
 
+// clang-format off
 MOZ_DEFINE_ENUM_CLASS_WITH_BASE(ScrollDirection, uint32_t, (
   eVertical,
   eHorizontal
 ));
+// clang-format on
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* GFX_LAYERSTYPES_H */
--- a/gfx/layers/RepaintRequest.h
+++ b/gfx/layers/RepaintRequest.h
@@ -23,21 +23,23 @@ template <typename T> struct ParamTraits
 
 namespace mozilla {
 namespace layers {
 
 struct RepaintRequest {
   friend struct IPC::ParamTraits<mozilla::layers::RepaintRequest>;
 public:
 
+  // clang-format off
   MOZ_DEFINE_ENUM_WITH_BASE_AT_CLASS_SCOPE(
     ScrollOffsetUpdateType, uint8_t, (
       eNone,             // The default; the scroll offset was not updated.
       eUserAction        // The scroll offset was updated by APZ.
   ));
+  // clang-format on
 
   RepaintRequest()
     : mScrollId(ScrollableLayerGuid::NULL_SCROLL_ID)
     , mPresShellResolution(1)
     , mCompositionBounds(0, 0, 0, 0)
     , mCumulativeResolution()
     , mDevPixelsPerCSSPixel(1)
     , mScrollOffset(0, 0)
--- a/gfx/layers/apz/public/GeckoContentController.h
+++ b/gfx/layers/apz/public/GeckoContentController.h
@@ -47,24 +47,26 @@ public:
    * if the user moves their finger after triggering the long-tap but before
    * lifting it).
    * The difference between eDoubleTap and eSecondTap is subtle - the eDoubleTap
    * is for an actual double-tap "gesture" while eSecondTap is for the same user
    * input but where a double-tap gesture is not allowed. This is used to fire
    * a click event with detail=2 to web content (similar to what a mouse double-
    * click would do).
    */
+  // clang-format off
   MOZ_DEFINE_ENUM_CLASS_AT_CLASS_SCOPE(
     TapType, (
       eSingleTap,
       eDoubleTap,
       eSecondTap,
       eLongTap,
       eLongTapUp
   ));
+  // clang-format on
 
   /**
    * Requests handling of a tap event. |aPoint| is in LD pixels, relative to the
    * current scroll offset.
    */
   virtual void HandleTap(TapType aType,
                          const LayoutDevicePoint& aPoint,
                          Modifiers aModifiers,
@@ -104,16 +106,17 @@ public:
    */
   virtual bool IsRepaintThread() = 0;
 
   /**
    * Runs the given task on the "repaint" thread.
    */
   virtual void DispatchToRepaintThread(already_AddRefed<Runnable> aTask) = 0;
 
+  // clang-format off
   MOZ_DEFINE_ENUM_CLASS_AT_CLASS_SCOPE(
     APZStateChange, (
       /**
        * APZ started modifying the view (including panning, zooming, and fling).
        */
       eTransformBegin,
       /**
        * APZ finished modifying the view.
@@ -129,16 +132,17 @@ public:
        */
       eStartPanning,
       /**
        * APZ finished processing a touch.
        * |aArg| is 1 if touch was a click, 0 otherwise.
        */
       eEndTouch
   ));
+  // clang-format on
 
   /**
    * General notices of APZ state changes for consumers.
    * |aGuid| identifies the APZC originating the state change.
    * |aChange| identifies the type of state change
    * |aArg| is used by some state changes to pass extra information (see
    *        the documentation for each state change above)
    */
--- a/gfx/layers/apz/src/APZUtils.h
+++ b/gfx/layers/apz/src/APZUtils.h
@@ -35,16 +35,17 @@ inline CancelAnimationFlags
 operator|(CancelAnimationFlags a, CancelAnimationFlags b)
 {
   return static_cast<CancelAnimationFlags>(static_cast<int>(a)
                                          | static_cast<int>(b));
 }
 
 typedef EnumSet<ScrollDirection> ScrollDirections;
 
+// clang-format off
 enum class ScrollSource {
   // scrollTo() or something similar.
   DOM,
 
   // Touch-screen or trackpad with gesture support.
   Touch,
 
   // Mouse wheel.
@@ -53,16 +54,17 @@ enum class ScrollSource {
   // Keyboard
   Keyboard,
 };
 
 MOZ_DEFINE_ENUM_CLASS_WITH_BASE(APZWheelAction, uint8_t, (
     Scroll,
     PinchZoom
 ))
+// clang-format on
 
 // Epsilon to be used when comparing 'float' coordinate values
 // with FuzzyEqualsAdditive. The rationale is that 'float' has 7 decimal
 // digits of precision, and coordinate values should be no larger than in the
 // ten thousands. Note also that the smallest legitimate difference in page
 // coordinates is 1 app unit, which is 1/60 of a (CSS pixel), so this epsilon
 // isn't too large.
 const float COORDINATE_EPSILON = 0.01f;
--- a/gfx/layers/apz/src/CheckerboardEvent.h
+++ b/gfx/layers/apz/src/CheckerboardEvent.h
@@ -22,24 +22,26 @@ namespace layers {
  * a contiguous set of frames where a given APZC was checkerboarding. The intent
  * of this class is to record enough information that it can provide actionable
  * steps to reduce the occurrence of checkerboarding. Furthermore, it records
  * information about the severity of the checkerboarding so as to allow
  * prioritizing the debugging of some checkerboarding events over others.
  */
 class CheckerboardEvent {
 public:
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     RendertraceProperty, (
       Page,
       PaintedCriticalDisplayPort,
       PaintedDisplayPort,
       RequestedDisplayPort,
       UserVisible
   ));
+  // clang-format on
 
   static const char* sDescriptions[sRendertracePropertyCount];
   static const char* sColors[sRendertracePropertyCount];
 
 public:
   explicit CheckerboardEvent(bool aRecordTrace);
 
   /**
--- a/gfx/layers/apz/src/KeyboardScrollAction.h
+++ b/gfx/layers/apz/src/KeyboardScrollAction.h
@@ -14,23 +14,25 @@ namespace mozilla {
 namespace layers {
 
 /**
  * This class represents a scrolling action to be performed on a scrollable layer.
  */
 struct KeyboardScrollAction final
 {
 public:
+  // clang-format off
   MOZ_DEFINE_ENUM_WITH_BASE_AT_CLASS_SCOPE(
     KeyboardScrollActionType, uint8_t, (
       eScrollCharacter,
       eScrollLine,
       eScrollPage,
       eScrollComplete
   ));
+  // clang-format on
 
   static nsIScrollableFrame::ScrollUnit
   GetScrollUnit(KeyboardScrollActionType aDeltaType);
 
   KeyboardScrollAction();
   KeyboardScrollAction(KeyboardScrollActionType aType, bool aForward);
 
   // The type of scroll to perform for this action
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -303,22 +303,24 @@ private:
 
 /***************************************************************************/
 
 // In the current xpconnect system there can only be one XPCJSContext.
 // So, xpconnect can only be used on one JSContext within the process.
 
 class WatchdogManager;
 
+// clang-format off
 MOZ_DEFINE_ENUM(WatchdogTimestampCategory, (
     TimestampWatchdogWakeup,
     TimestampWatchdogHibernateStart,
     TimestampWatchdogHibernateStop,
     TimestampContextStateChange
 ));
+// clang-format on
 
 class AsyncFreeSnowWhite;
 
 class XPCJSContext final : public mozilla::CycleCollectedJSContext
                          , public mozilla::LinkedListElement<XPCJSContext>
 {
 public:
     static void InitTLS();
--- a/mfbt/tests/TestDefineEnum.cpp
+++ b/mfbt/tests/TestDefineEnum.cpp
@@ -30,29 +30,31 @@ static_assert(kTestEnum2Count == 3, "Inc
 //       correct underlying types. To do this, we need an |UnderlyingType|
 //       type trait, which needs compiler support (recent versions of
 //       compilers in the GCC family provide an |__underlying_type| builtin
 //       for this purpose.
 
 // Sanity test for MOZ_DEFINE_ENUM[_CLASS]_AT_CLASS_SCOPE.
 
 struct TestClass {
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     TestEnum3, (
       EnumeratorA,
       EnumeratorB,
       EnumeratorC
   ));
 
   MOZ_DEFINE_ENUM_CLASS_AT_CLASS_SCOPE(
     TestEnum4, (
       A,
       B,
       C
   ));
+  // clang-format on
 
   static_assert(EnumeratorA == 0, "Unexpected enumerator value");
   static_assert(EnumeratorB == 1, "Unexpected enumerator value");
   static_assert(EnumeratorC == 2, "Unexpected enumerator value");
   static_assert(sHighestTestEnum3 == EnumeratorC, "Incorrect highest value");
   static_assert(sTestEnum3Count == 3, "Incorrect enumerator count");
 
   static_assert(TestEnum4::A == TestEnum4(0), "Unexpected enumerator value");
--- a/toolkit/recordreplay/ipc/JSControl.h
+++ b/toolkit/recordreplay/ipc/JSControl.h
@@ -32,16 +32,17 @@ namespace js {
 
 // Identification for a position where a breakpoint can be installed in a child
 // process. Breakpoint positions describe all places between checkpoints where
 // the child process can pause and be inspected by the middleman. A particular
 // BreakpointPosition can be reached any number of times during execution of
 // the process.
 struct BreakpointPosition
 {
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(Kind, (
     Invalid,
 
     // Break at a script offset. Requires script/offset.
     Break,
 
     // Break for an on-step handler within a frame.
     // Requires script/offset/frameIndex.
@@ -58,16 +59,17 @@ struct BreakpointPosition
     NewScript,
 
     // Break when a message is logged to the web console.
     ConsoleMessage,
 
     // Break when NewTimeWarpTarget() is called.
     WarpTarget
   ));
+  // clang-format on
 
   Kind mKind;
 
   // Optional information associated with the breakpoint.
   uint32_t mScript;
   uint32_t mOffset;
   uint32_t mFrameIndex;
 
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -28,26 +28,28 @@ namespace layers {
 class APZInputBridgeChild;
 class PAPZInputBridgeParent;
 }
 
 namespace dom {
 class Touch;
 } // namespace dom
 
+// clang-format off
 MOZ_DEFINE_ENUM(
   InputType, (
     MULTITOUCH_INPUT,
     MOUSE_INPUT,
     PANGESTURE_INPUT,
     PINCHGESTURE_INPUT,
     TAPGESTURE_INPUT,
     SCROLLWHEEL_INPUT,
     KEYBOARD_INPUT
 ));
+// clang-format on
 
 class MultiTouchInput;
 class MouseInput;
 class PanGestureInput;
 class PinchGestureInput;
 class TapGestureInput;
 class ScrollWheelInput;
 class KeyboardInput;
@@ -183,23 +185,25 @@ public:
  * this copying from WidgetTouchEvent functionality can only be used on the main
  * thread.
  *
  * Stores an array of SingleTouchData.
  */
 class MultiTouchInput : public InputData
 {
 public:
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     MultiTouchType, (
       MULTITOUCH_START,
       MULTITOUCH_MOVE,
       MULTITOUCH_END,
       MULTITOUCH_CANCEL
   ));
+  // clang-format on
 
   MultiTouchInput(MultiTouchType aType, uint32_t aTime, TimeStamp aTimeStamp,
                   Modifiers aModifiers);
   MultiTouchInput();
   MultiTouchInput(const MultiTouchInput& aOther);
   explicit MultiTouchInput(const WidgetTouchEvent& aTouchEvent);
   // This conversion from WidgetMouseEvent to MultiTouchInput is needed because
   // on the B2G emulator we can only receive mouse events, but we need to be
@@ -231,16 +235,17 @@ class MouseInput : public InputData
 protected:
   friend mozilla::layers::APZInputBridgeChild;
   friend mozilla::layers::PAPZInputBridgeParent;
 
   MouseInput();
 
 public:
 
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     MouseType, (
       MOUSE_NONE,
       MOUSE_MOVE,
       MOUSE_DOWN,
       MOUSE_UP,
       MOUSE_DRAG_START,
       MOUSE_DRAG_END,
@@ -251,16 +256,17 @@ public:
 
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     ButtonType, (
       LEFT_BUTTON,
       MIDDLE_BUTTON,
       RIGHT_BUTTON,
       NONE
   ));
+  // clang-format on
 
   MouseInput(MouseType aType, ButtonType aButtonType, uint16_t aInputSource,
              int16_t aButtons, const ScreenPoint& aPoint, uint32_t aTime,
              TimeStamp aTimeStamp, Modifiers aModifiers);
   explicit MouseInput(const WidgetMouseEventBase& aMouseEvent);
 
   bool IsLeftButton() const;
 
@@ -286,16 +292,17 @@ class PanGestureInput : public InputData
 {
 protected:
   friend mozilla::layers::APZInputBridgeChild;
   friend mozilla::layers::PAPZInputBridgeParent;
 
   PanGestureInput();
 
 public:
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     PanGestureType, (
       // MayStart: Dispatched before any actual panning has occurred but when a
       // pan gesture is probably about to start, for example when the user
       // starts touching the touchpad. Should interrupt any ongoing APZ
       // animation and can be used to trigger scrollability indicators (e.g.
       // flashing overlay scrollbars).
       PANGESTURE_MAYSTART,
@@ -331,16 +338,17 @@ public:
       // MomentumPan: The actual momentum motion by mPanDisplacement.
       PANGESTURE_MOMENTUMPAN,
 
       // MomentumEnd: The momentum animation has ended, for example because the
       // momentum velocity has gone below the stopping threshold, or because the
       // user has stopped the animation by putting their fingers on a touchpad.
       PANGESTURE_MOMENTUMEND
   ));
+  // clang-format on
 
   PanGestureInput(PanGestureType aType,
                   uint32_t aTime,
                   TimeStamp aTimeStamp,
                   const ScreenPoint& aPanStartPoint,
                   const ScreenPoint& aPanDisplacement,
                   Modifiers aModifiers);
 
@@ -406,22 +414,24 @@ class PinchGestureInput : public InputDa
 {
 protected:
   friend mozilla::layers::APZInputBridgeChild;
   friend mozilla::layers::PAPZInputBridgeParent;
 
   PinchGestureInput();
 
 public:
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     PinchGestureType, (
       PINCHGESTURE_START,
       PINCHGESTURE_SCALE,
       PINCHGESTURE_END
   ));
+  // clang-format on
 
   // Construct a pinch gesture from a Screen point.
   // (Technically, we should take the span values in Screen pixels as well,
   // but that would require also storing them in Screen pixels and then
   // converting them in TransformToLocal() like the focus point. Since pinch
   // gesture events are processed by the root content APZC, the only transform
   // between Screen and ParentLayer pixels should be a translation, which is
   // irrelevant to span values, so we don't bother.)
@@ -489,26 +499,28 @@ class TapGestureInput : public InputData
 {
 protected:
   friend mozilla::layers::APZInputBridgeChild;
   friend mozilla::layers::PAPZInputBridgeParent;
 
   TapGestureInput();
 
 public:
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     TapGestureType, (
       TAPGESTURE_LONG,
       TAPGESTURE_LONG_UP,
       TAPGESTURE_UP,
       TAPGESTURE_CONFIRMED,
       TAPGESTURE_DOUBLE,
       TAPGESTURE_SECOND, // See GeckoContentController::TapType::eSecondTap
       TAPGESTURE_CANCEL
   ));
+  // clang-format on
 
   // Construct a tap gesture from a Screen point.
   // mLocalPoint remains (0,0) unless it's set later.
   TapGestureInput(TapGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
                   const ScreenIntPoint& aPoint, Modifiers aModifiers);
 
   // Construct a tap gesture from a ParentLayer point.
   // mPoint remains (0,0) unless it's set later.
@@ -538,31 +550,33 @@ protected:
   friend mozilla::layers::APZInputBridgeChild;
   friend mozilla::layers::PAPZInputBridgeParent;
 
   typedef mozilla::layers::APZWheelAction APZWheelAction;
 
   ScrollWheelInput();
 
 public:
+  // clang-format off
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     ScrollDeltaType, (
-      // There are three kinds of scroll delta modes in Gecko: "page", "line" and
-      // "pixel".
+      // There are three kinds of scroll delta modes in Gecko: "page", "line"
+      // and "pixel".
       SCROLLDELTA_LINE,
       SCROLLDELTA_PAGE,
       SCROLLDELTA_PIXEL
   ));
 
   MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
     ScrollMode, (
       SCROLLMODE_INSTANT,
       SCROLLMODE_SMOOTH
     )
   );
+  // clang-format on
 
   ScrollWheelInput(uint32_t aTime, TimeStamp aTimeStamp, Modifiers aModifiers,
                    ScrollMode aScrollMode, ScrollDeltaType aDeltaType,
                    const ScreenPoint& aOrigin, double aDeltaX, double aDeltaY,
                    bool aAllowToOverrideSystemScrollSpeed,
                    WheelDeltaAdjustmentStrategy aWheelDeltaAdjustmentStrategy);
   explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);