Bug 1079314 - Remove the mWritingMode field from logical-coordinate objects in non-debug builds. r=smontagu
authorJonathan Kew <jkew@mozilla.com>
Wed, 08 Oct 2014 10:32:50 +0100
changeset 232556 681c4450639e2d9c7ccca1e48514ed4a35bf6552
parent 232555 931302c829b4e78ad355063a42622ad176e124e7
child 232557 1b195cb0d08d40117862c78776b757e93017e439
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmontagu
bugs1079314
milestone35.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 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,