Bug 1543304 - Add MOZ_DBG support for nsCSSPropertyID and nsCSSPropertyIDSet; r=heycam
authorBrian Birtles <birtles@gmail.com>
Sun, 14 Apr 2019 23:48:05 +0000
changeset 531327 587b7bc9ad81e868c672c540907843bf46658071
parent 531326 fa9332a8ea937098a1a6d79ed4bc9028e3917e62
child 531328 a59f06022a956d1cc3032f6713d5ec122096c299
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1543304
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 1543304 - Add MOZ_DBG support for nsCSSPropertyID and nsCSSPropertyIDSet; r=heycam Differential Revision: https://phabricator.services.mozilla.com/D26856
layout/style/nsCSSPropertyID.h.in
layout/style/nsCSSPropertyIDSet.h
layout/style/nsCSSProps.h
--- a/layout/style/nsCSSPropertyID.h.in
+++ b/layout/style/nsCSSPropertyID.h.in
@@ -30,16 +30,19 @@ enum nsCSSPropertyID {
   // property.
   eCSSPropertyExtra_no_properties,
   eCSSPropertyExtra_all_properties,
 
   // Extra value to represent custom properties (--*).
   eCSSPropertyExtra_variable,
 };
 
+// MOZ_DBG support is defined in nsCSSProps.h since it depends on
+// nsCSSProps::GetStringValue
+
 const nsCSSPropertyID
   eCSSProperty_COUNT_no_shorthands = $longhand_count;
 const nsCSSPropertyID
   eCSSProperty_COUNT = $shorthand_count;
 const nsCSSPropertyID
   eCSSProperty_COUNT_with_aliases = eCSSPropertyExtra_no_properties;
 
 namespace mozilla {
--- a/layout/style/nsCSSPropertyIDSet.h
+++ b/layout/style/nsCSSPropertyIDSet.h
@@ -2,25 +2,26 @@
  * 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/. */
 
 /* bit vectors for sets of CSS properties */
 
 #ifndef nsCSSPropertyIDSet_h__
 #define nsCSSPropertyIDSet_h__
 
-#include "mozilla/ArrayUtils.h"
+#include <initializer_list>
+#include <limits.h>  // for CHAR_BIT
+#include <ostream>
 
-#include "nsCSSPropertyID.h"
-#include <limits.h>  // for CHAR_BIT
-#include <initializer_list>
-
+#include "mozilla/ArrayUtils.h"
 // For COMPOSITOR_ANIMATABLE_PROPERTY_LIST and
 // COMPOSITOR_ANIMATABLE_PROPERTY_LIST_LENGTH
 #include "mozilla/CompositorAnimatableProperties.h"
+#include "nsCSSProps.h"  // For operator<< for nsCSSPropertyID
+#include "nsCSSPropertyID.h"
 
 /**
  * nsCSSPropertyIDSet maintains a set of non-shorthand CSS properties.  In
  * other words, for each longhand CSS property we support, it has a bit
  * for whether that property is in the set.
  */
 class nsCSSPropertyIDSet {
  public:
@@ -265,9 +266,20 @@ class nsCSSPropertyIDSet {
 
   Iterator begin() const { return Iterator::BeginIterator(*this); }
   Iterator end() const { return Iterator::EndIterator(*this); }
 
  private:
   property_set_type mProperties[kChunkCount];
 };
 
+// MOZ_DBG support
+
+inline std::ostream& operator<<(std::ostream& aOut,
+                                const nsCSSPropertyIDSet& aPropertySet) {
+  AutoTArray<nsCSSPropertyID, 16> properties;
+  for (nsCSSPropertyID property : aPropertySet) {
+    properties.AppendElement(property);
+  }
+  return aOut << properties;
+}
+
 #endif /* !defined(nsCSSPropertyIDSet_h__) */
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -8,17 +8,19 @@
  * methods for dealing with CSS properties and tables of the keyword
  * values they accept
  */
 
 #ifndef nsCSSProps_h___
 #define nsCSSProps_h___
 
 #include <limits>
+#include <ostream>
 #include <type_traits>
+
 #include "nsString.h"
 #include "nsCSSPropertyID.h"
 #include "nsStyleStructFwd.h"
 #include "nsCSSKeywords.h"
 #include "mozilla/CSSEnabledState.h"
 #include "mozilla/CSSPropFlags.h"
 #include "mozilla/UseCounter.h"
 #include "mozilla/EnumTypeTraits.h"
@@ -307,9 +309,15 @@ class nsCSSProps {
   static const KTableEntry kLineHeightKTable[];
   static const KTableEntry kTextAlignKTable[];
   static const KTableEntry kTextDecorationStyleKTable[];
   static const KTableEntry kTextEmphasisStyleShapeKTable[];
   static const KTableEntry kTextOverflowKTable[];
   static const KTableEntry kVerticalAlignKTable[];
 };
 
+// MOZ_DBG support for nsCSSPropertyID
+
+inline std::ostream& operator<<(std::ostream& aOut, nsCSSPropertyID aProperty) {
+  return aOut << nsCSSProps::GetStringValue(aProperty);
+}
+
 #endif /* nsCSSProps_h___ */