Bug 1079314 - Remove the mWritingMode field from logical-coordinate objects in non-debug builds. r=smontagu
☠☠ backed out by 931302c829b4 ☠ ☠
authorJonathan Kew <jkew@mozilla.com>
Wed, 08 Oct 2014 10:32:50 +0100
changeset 209335 b818ba8aabc28188ee0521778ef6712c178ba146
parent 209334 3e40213d4a2175c167406ab80cb5b36f66403ee1
child 209336 1632a36342d4fd4926960144903ccdac12f48f5c
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerssmontagu
bugs1079314
milestone35.0a1
Bug 1079314 - Remove the mWritingMode field from logical-coordinate objects in non-debug builds. r=smontagu
layout/generic/WritingModes.h
layout/tables/nsTableOuterFrame.cpp
--- a/layout/generic/WritingModes.h
+++ b/layout/generic/WritingModes.h
@@ -29,17 +29,17 @@
 // Methods in logical-coordinate classes that take another logical-coordinate
 // object as a parameter should call CHECK_WRITING_MODE on it to verify that
 // the writing modes match.
 // (In some cases, there are internal (private) methods that don't do this;
 // such methods should only be used by other methods that have already checked
 // the writing modes.)
 
 #define CHECK_WRITING_MODE(param) \
-   NS_ASSERTION(param == mWritingMode, "writing-mode mismatch")
+   NS_ASSERTION(param == GetWritingMode(), "writing-mode mismatch")
 
 namespace mozilla {
 // Logical side constants for use in various places.
 enum LogicalSide { eLogicalSideBStart, eLogicalSideBEnd,
                    eLogicalSideIStart, eLogicalSideIEnd };
 
 enum LogicalSideBits {
   eLogicalSideBitsNone   = 0,
@@ -558,17 +558,19 @@ private:
   {
     return mPoint.x;
   }
   nscoord& B() // block-axis
   {
     return mPoint.y;
   }
 
+#ifdef DEBUG
   WritingMode mWritingMode;
+#endif
 
   // We use an nsPoint to hold the coordinates, but reinterpret its .x and .y
   // fields as the inline and block directions. Hence, this is not exposed
   // directly, but only through accessors that will map them according to the
   // writing mode.
   nsPoint mPoint;
 };
 
@@ -678,45 +680,59 @@ public:
    */
   LogicalSize ConvertTo(WritingMode aToMode, WritingMode aFromMode) const
   {
     CHECK_WRITING_MODE(aFromMode);
     return aToMode == aFromMode ?
       *this : LogicalSize(aToMode, GetPhysicalSize(aFromMode));
   }
 
+  /**
+   * Test if a size is (0, 0).
+   */
+  bool IsAllZero() const
+  {
+    return ISize() == 0 && BSize() == 0;
+  }
+
+  /**
+   * Various binary operators on LogicalSize. These are valid ONLY for operands
+   * that share the same writing mode.
+   */
   bool operator==(const LogicalSize& aOther) const
   {
-    return mWritingMode == aOther.mWritingMode && mSize == aOther.mSize;
+    CHECK_WRITING_MODE(aOther.GetWritingMode());
+    return mSize == aOther.mSize;
   }
 
   bool operator!=(const LogicalSize& aOther) const
   {
-    return mWritingMode != aOther.mWritingMode || mSize != aOther.mSize;
+    CHECK_WRITING_MODE(aOther.GetWritingMode());
+    return mSize != aOther.mSize;
   }
 
   LogicalSize operator+(const LogicalSize& aOther) const
   {
     CHECK_WRITING_MODE(aOther.GetWritingMode());
-    return LogicalSize(mWritingMode, ISize() + aOther.ISize(),
-                                     BSize() + aOther.BSize());
+    return LogicalSize(GetWritingMode(), ISize() + aOther.ISize(),
+                                         BSize() + aOther.BSize());
   }
   LogicalSize& operator+=(const LogicalSize& aOther)
   {
     CHECK_WRITING_MODE(aOther.GetWritingMode());
     ISize() += aOther.ISize();
     BSize() += aOther.BSize();
     return *this;
   }
 
   LogicalSize operator-(const LogicalSize& aOther) const
   {
     CHECK_WRITING_MODE(aOther.GetWritingMode());
-    return LogicalSize(mWritingMode, ISize() - aOther.ISize(),
-                                     BSize() - aOther.BSize());
+    return LogicalSize(GetWritingMode(), ISize() - aOther.ISize(),
+                                         BSize() - aOther.BSize());
   }
   LogicalSize& operator-=(const LogicalSize& aOther)
   {
     CHECK_WRITING_MODE(aOther.GetWritingMode());
     ISize() -= aOther.ISize();
     BSize() -= aOther.BSize();
     return *this;
   }
@@ -745,17 +761,19 @@ private:
   {
     return mSize.width;
   }
   nscoord& BSize() // block-size
   {
     return mSize.height;
   }
 
+#ifdef DEBUG
   WritingMode mWritingMode;
+#endif
   nsSize      mSize;
 };
 
 /**
  * Flow-relative margin
  */
 class LogicalMargin {
 public:
@@ -1041,17 +1059,19 @@ private:
   {
     return mMargin.LeftRight();
   }
   nscoord BStartEnd() const // block margins
   {
     return mMargin.TopBottom();
   }
 
+#ifdef DEBUG
   WritingMode mWritingMode;
+#endif
   nsMargin    mMargin;
 };
 
 /**
  * Flow-relative rectangle
  */
 class LogicalRect {
 public:
@@ -1471,15 +1491,17 @@ private:
   {
     return mRect.y;
   }
   nscoord& BSize() // block-size
   {
     return mRect.height;
   }
 
+#ifdef DEBUG
   WritingMode mWritingMode;
+#endif
   nsRect      mRect;
 };
 
 } // namespace mozilla
 
 #endif // WritingModes_h_
--- a/layout/tables/nsTableOuterFrame.cpp
+++ b/layout/tables/nsTableOuterFrame.cpp
@@ -507,18 +507,17 @@ nsTableOuterFrame::ComputeAutoSize(nsRen
                                    const LogicalSize& aCBSize,
                                    nscoord aAvailableISize,
                                    const LogicalSize& aMargin,
                                    const LogicalSize& aBorder,
                                    const LogicalSize& aPadding,
                                    bool aShrinkWrap)
 {
   nscoord kidAvailableWidth = aAvailableISize - aMargin.ISize(aWM);
-  NS_ASSERTION(aBorder == LogicalSize(aWM) &&
-               aPadding == LogicalSize(aWM),
+  NS_ASSERTION(aBorder.IsAllZero() && aPadding.IsAllZero(),
                "Table outer frames cannot have borders or paddings");
 
   // When we're shrink-wrapping, our auto size needs to wrap around the
   // actual size of the table, which (if it is specified as a percent)
   // could be something that is not reflected in our GetMinISize and
   // GetPrefISize.  See bug 349457 for an example.
 
   // XXX The use of aCBSize.GetPhysicalSize(aWM) below is temporary,