Bug 1319672 Part 2 - Check the line direction is not changed. r=dbaron
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 23 Nov 2016 18:10:23 +0800
changeset 324626 cb5869f00c9f6b1f6f9360e0883e958050e51502
parent 324625 81eb4fbbb3ef691d439fce501778f3ef19d05f2f
child 324627 b41f682fed503d160746aa41254b3ba66d4afa7b
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersdbaron
bugs1319672
milestone53.0a1
Bug 1319672 Part 2 - Check the line direction is not changed. r=dbaron Since the line direction affects the interpretation of float right or left, we should check aWM has the same line direction as mWritingMode. And this also guarantees that float added by AddFloat() has the same line direction as when querying the available space via GetFlowArea(). MozReview-Commit-ID: FGxVFbo910g
layout/generic/nsFloatManager.cpp
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -111,27 +111,28 @@ void nsFloatManager::Shutdown()
     if (floatManager)
       free(floatManager);
   }
 
   // Disable further caching.
   sCachedFloatManagerCount = -1;
 }
 
-#define CHECK_BLOCK_DIR(aWM) \
-  NS_ASSERTION((aWM).GetBlockDir() == mWritingMode.GetBlockDir(), \
-  "incompatible writing modes")
+#define CHECK_BLOCK_AND_LINE_DIR(aWM) \
+  NS_ASSERTION((aWM).GetBlockDir() == mWritingMode.GetBlockDir() &&     \
+               (aWM).IsLineInverted() == mWritingMode.IsLineInverted(), \
+               "incompatible writing modes")
 
 nsFlowAreaRect
 nsFloatManager::GetFlowArea(WritingMode aWM, nscoord aBCoord, nscoord aBSize,
                             BandInfoType aBandInfoType, ShapeType aShapeType,
                             LogicalRect aContentArea, SavedState* aState,
                             const nsSize& aContainerSize) const
 {
-  CHECK_BLOCK_DIR(aWM);
+  CHECK_BLOCK_AND_LINE_DIR(aWM);
   NS_ASSERTION(aBSize >= 0, "unexpected max block size");
   NS_ASSERTION(aContentArea.ISize(aWM) >= 0,
                "unexpected content area inline size");
 
   nscoord blockStart = aBCoord + mBlockStart;
   if (blockStart < nscoord_MIN) {
     NS_WARNING("bad value");
     blockStart = nscoord_MIN;
@@ -259,17 +260,17 @@ nsFloatManager::GetFlowArea(WritingMode 
   return nsFlowAreaRect(aWM, inlineStart, blockStart - mBlockStart,
                         lineRight - lineLeft, blockSize, haveFloats);
 }
 
 nsresult
 nsFloatManager::AddFloat(nsIFrame* aFloatFrame, const LogicalRect& aMarginRect,
                          WritingMode aWM, const nsSize& aContainerSize)
 {
-  CHECK_BLOCK_DIR(aWM);
+  CHECK_BLOCK_AND_LINE_DIR(aWM);
   NS_ASSERTION(aMarginRect.ISize(aWM) >= 0, "negative inline size!");
   NS_ASSERTION(aMarginRect.BSize(aWM) >= 0, "negative block size!");
 
   FloatInfo info(aFloatFrame, mLineLeft, mBlockStart, aMarginRect, aWM,
                  aContainerSize);
 
   // Set mLeftBEnd and mRightBEnd.
   if (HasAnyFloats()) {