Bug 1268342 part 2 - Store writing mode of frame in PerFrameData. r?jfkthame draft
authorXidorn Quan <me@upsuper.org>
Thu, 26 May 2016 21:19:50 +1000
changeset 371876 2db7e39f8e00912d1a45e1f116c7fe8087b36f95
parent 371875 225a54a0052eb6d86bfe03008aaa84859c677b8a
child 371877 d90d537f4959b1c3188e80b9cad2d8ed949fec30
push id19375
push userxquan@mozilla.com
push dateFri, 27 May 2016 00:55:38 +0000
reviewersjfkthame
bugs1268342
milestone49.0a1
Bug 1268342 part 2 - Store writing mode of frame in PerFrameData. r?jfkthame MozReview-Commit-ID: 66ZWj3EdCdh
layout/generic/nsLineLayout.cpp
layout/generic/nsLineLayout.h
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -241,17 +241,17 @@ nsLineLayout::BeginLineReflow(nscoord aI
   if (frame->GetType() == nsGkAtoms::rubyTextContainerFrame) {
     // Ruby text container won't be reflowed via ReflowFrame, hence the
     // relative positioning information should be recorded here.
     MOZ_ASSERT(mBaseLineLayout != this);
     pfd->mRelativePos =
       mBlockReflowState->mStyleDisplay->IsRelativelyPositionedStyle();
     if (pfd->mRelativePos) {
       MOZ_ASSERT(
-        mBlockReflowState->GetWritingMode() == frame->GetWritingMode(),
+        mBlockReflowState->GetWritingMode() == pfd->mWritingMode,
         "mBlockReflowState->frame == frame, "
         "hence they should have identical writing mode");
       pfd->mOffsets = mBlockReflowState->ComputedLogicalOffsets();
     }
   }
 }
 
 void
@@ -680,23 +680,23 @@ nsLineLayout::NewPerFrameData(nsIFrame* 
   pfd->mIsNonWhitespaceTextFrame = false;
   pfd->mIsLetterFrame = false;
   pfd->mRecomputeOverflow = false;
   pfd->mIsBullet = false;
   pfd->mSkipWhenTrimmingWhitespace = false;
   pfd->mIsEmpty = false;
   pfd->mIsLinkedToBase = false;
 
-  WritingMode frameWM = aFrame->GetWritingMode();
+  pfd->mWritingMode = aFrame->GetWritingMode();
   WritingMode lineWM = mRootSpan->mWritingMode;
   pfd->mBounds = LogicalRect(lineWM);
   pfd->mOverflowAreas.Clear();
   pfd->mMargin = LogicalMargin(lineWM);
   pfd->mBorderPadding = LogicalMargin(lineWM);
-  pfd->mOffsets = LogicalMargin(frameWM);
+  pfd->mOffsets = LogicalMargin(pfd->mWritingMode);
 
   pfd->mJustificationInfo = JustificationInfo();
   pfd->mJustificationAssignment = JustificationAssignment();
 
 #ifdef DEBUG
   pfd->mBlockDirAlign = 0xFF;
   outerLineLayout->mFramesAllocated++;
 #endif
@@ -831,17 +831,17 @@ nsLineLayout::ReflowFrame(nsIFrame* aFra
     NS_ASSERTION(!hasLineOffset, "LineBaselineOffset was set but was not expected");
 #endif
   }
 
   mJustificationInfo = JustificationInfo();
 
   // Stash copies of some of the computed state away for later
   // (block-direction alignment, for example)
-  WritingMode frameWM = aFrame->GetWritingMode();
+  WritingMode frameWM = pfd->mWritingMode;
   WritingMode lineWM = mRootSpan->mWritingMode;
 
   // NOTE: While the inline direction coordinate remains relative to the
   // parent span, the block direction coordinate is fixed at the top
   // edge for the line. During VerticalAlignFrames we will repair this
   // so that the block direction coordinate is properly set and relative
   // to the appropriate span.
   pfd->mBounds.IStart(lineWM) = psd->mICoord;
@@ -1432,17 +1432,17 @@ nsLineLayout::CanPlaceFrame(PerFrameData
 void
 nsLineLayout::PlaceFrame(PerFrameData* pfd, nsHTMLReflowMetrics& aMetrics)
 {
   WritingMode lineWM = mRootSpan->mWritingMode;
 
   // If the frame's block direction does not match the line's, we can't use
   // its ascent; instead, treat it as a block with baseline at the block-end
   // edge (or block-begin in the case of an "inverted" line).
-  if (pfd->mFrame->GetWritingMode().GetBlockDir() != lineWM.GetBlockDir()) {
+  if (pfd->mWritingMode.GetBlockDir() != lineWM.GetBlockDir()) {
     pfd->mAscent = lineWM.IsLineInverted() ? 0 : aMetrics.BSize(lineWM);
   } else {
     if (aMetrics.BlockStartAscent() == nsHTMLReflowMetrics::ASK_FOR_BASELINE) {
       pfd->mAscent = pfd->mFrame->GetLogicalBaseline(lineWM);
     } else {
       pfd->mAscent = aMetrics.BlockStartAscent();
     }
   }
@@ -1792,17 +1792,17 @@ nsLineLayout::VerticalAlignFrames(PerSpa
   nsFrame::ListTag(stdout, spanFrame);
   printf(": preMode=%s strictMode=%s w/h=%d,%d emptyContinuation=%s",
          preMode ? "yes" : "no",
          mPresContext->CompatibilityMode() != eCompatibility_NavQuirks ? "yes" : "no",
          spanFramePFD->mBounds.ISize(lineWM),
          spanFramePFD->mBounds.BSize(lineWM),
          emptyContinuation ? "yes" : "no");
   if (psd != mRootSpan) {
-    WritingMode frameWM = spanFramePFD->mFrame->GetWritingMode();
+    WritingMode frameWM = spanFramePFD->mWritingMode;
     printf(" bp=%d,%d,%d,%d margin=%d,%d,%d,%d",
            spanFramePFD->mBorderPadding.Top(lineWM),
            spanFramePFD->mBorderPadding.Right(lineWM),
            spanFramePFD->mBorderPadding.Bottom(lineWM),
            spanFramePFD->mBorderPadding.Left(lineWM),
            spanFramePFD->mMargin.Top(lineWM),
            spanFramePFD->mMargin.Right(lineWM),
            spanFramePFD->mMargin.Bottom(lineWM),
@@ -3254,17 +3254,17 @@ nsLineLayout::TextAlignLine(nsLineBox* a
 void
 nsLineLayout::ApplyRelativePositioning(PerFrameData* aPFD)
 {
   if (!aPFD->mRelativePos) {
     return;
   }
 
   nsIFrame* frame = aPFD->mFrame;
-  WritingMode frameWM = frame->GetWritingMode();
+  WritingMode frameWM = aPFD->mWritingMode;
   LogicalPoint origin = frame->GetLogicalPosition(ContainerSize());
   // right and bottom are handled by
   // nsHTMLReflowState::ComputeRelativeOffsets
   nsHTMLReflowState::ApplyRelativePositioning(frame, frameWM,
                                               aPFD->mOffsets, &origin,
                                               ContainerSize());
   frame->SetPosition(frameWM, origin, ContainerSize());
 }
--- a/layout/generic/nsLineLayout.h
+++ b/layout/generic/nsLineLayout.h
@@ -470,16 +470,17 @@ protected:
     bool mRecomputeOverflow : 1;
     bool mIsBullet : 1;
     bool mSkipWhenTrimmingWhitespace : 1;
     bool mIsEmpty : 1;
     bool mIsLinkedToBase : 1;
 
     // Other state we use
     uint8_t mBlockDirAlign;
+    mozilla::WritingMode mWritingMode;
 
     PerFrameData* Last() {
       PerFrameData* pfd = this;
       while (pfd->mNext) {
         pfd = pfd->mNext;
       }
       return pfd;
     }