Bug 1079314 - Remove the mWritingMode field from logical-coordinate objects in non-debug builds. r=smontagu
--- 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,