Bug 1055667 part 1 - Allow inline direction margin of ruby base/text boxes. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 15 Jan 2015 20:02:11 +1100
changeset 223952 400423459c99
parent 223951 798b88e6a1b2
child 223953 a0ce5974c7dd
push id28112
push usercbook@mozilla.com
push date2015-01-15 13:19 +0000
treeherdermozilla-central@206bf1a98cd7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1055667
milestone38.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 1055667 part 1 - Allow inline direction margin of ruby base/text boxes. r=dbaron
layout/generic/nsRubyBaseContainerFrame.cpp
--- a/layout/generic/nsRubyBaseContainerFrame.cpp
+++ b/layout/generic/nsRubyBaseContainerFrame.cpp
@@ -663,50 +663,52 @@ nsRubyBaseContainerFrame::ReflowOneColum
       // and text transformation (text-transform), and ignores elements
       // (considers only the textContent of the boxes). Which means
       // using the content tree text comparison is correct.
       if (annotationText.Equals(baseText)) {
         textFrame->AddStateBits(NS_RUBY_TEXT_FRAME_AUTOHIDE);
       } else {
         textFrame->RemoveStateBits(NS_RUBY_TEXT_FRAME_AUTOHIDE);
       }
-
-      nsReflowStatus reflowStatus;
-      nsHTMLReflowMetrics metrics(*textReflowStates[i]);
       RubyUtils::ClearReservedISize(textFrame);
 
       bool pushedFrame;
-      textReflowStates[i]->mLineLayout->ReflowFrame(textFrame, reflowStatus,
-                                                    &metrics, pushedFrame);
+      nsReflowStatus reflowStatus;
+      nsLineLayout* lineLayout = textReflowStates[i]->mLineLayout;
+      nscoord textIStart = lineLayout->GetCurrentICoord();
+      lineLayout->ReflowFrame(textFrame, reflowStatus, nullptr, pushedFrame);
       MOZ_ASSERT(!NS_INLINE_IS_BREAK(reflowStatus) && !pushedFrame,
                  "Any line break inside ruby box should has been suppressed");
-      columnISize = std::max(columnISize, metrics.ISize(lineWM));
+      nscoord textISize = lineLayout->GetCurrentICoord() - textIStart;
+      columnISize = std::max(columnISize, textISize);
     }
   }
   if (aReflowState.mAllowLineBreak &&
       ShouldBreakBefore(baseReflowState, columnISize)) {
     // Since ruby text container uses an independent line layout, it
     // may successfully place a frame because the line is empty while
     // the line of base container is not.
     aStatus = NS_INLINE_LINE_BREAK_BEFORE();
     return 0;
   }
 
   // Reflow the base frame
   if (aColumn.mBaseFrame) {
-    nsReflowStatus reflowStatus;
-    nsHTMLReflowMetrics metrics(baseReflowState);
     RubyUtils::ClearReservedISize(aColumn.mBaseFrame);
 
     bool pushedFrame;
-    baseReflowState.mLineLayout->ReflowFrame(aColumn.mBaseFrame, reflowStatus,
-                                             &metrics, pushedFrame);
+    nsReflowStatus reflowStatus;
+    nsLineLayout* lineLayout = baseReflowState.mLineLayout;
+    nscoord baseIStart = lineLayout->GetCurrentICoord();
+    lineLayout->ReflowFrame(aColumn.mBaseFrame, reflowStatus,
+                            nullptr, pushedFrame);
     MOZ_ASSERT(!NS_INLINE_IS_BREAK(reflowStatus) && !pushedFrame,
                "Any line break inside ruby box should has been suppressed");
-    columnISize = std::max(columnISize, metrics.ISize(lineWM));
+    nscoord baseISize = lineLayout->GetCurrentICoord() - baseIStart;
+    columnISize = std::max(columnISize, baseISize);
   }
 
   // Align all the line layout to the new coordinate.
   nscoord icoord = istart + columnISize;
   nscoord deltaISize = icoord - baseReflowState.mLineLayout->GetCurrentICoord();
   if (deltaISize > 0) {
     baseReflowState.mLineLayout->AdvanceICoord(deltaISize);
     if (aColumn.mBaseFrame) {
@@ -830,19 +832,20 @@ nsRubyBaseContainerFrame::ReflowSpans(co
        i < iend; i++) {
     nsRubyTextContainerFrame* container = aReflowState.mTextContainers[i];
     if (!container->IsSpanContainer()) {
       continue;
     }
 
     nsIFrame* rtFrame = container->GetFirstPrincipalChild();
     nsReflowStatus reflowStatus;
-    nsHTMLReflowMetrics metrics(*aReflowState.mTextReflowStates[i]);
     bool pushedFrame;
-    aReflowState.mTextReflowStates[i]->mLineLayout->
-      ReflowFrame(rtFrame, reflowStatus, &metrics, pushedFrame);
+    nsLineLayout* lineLayout = aReflowState.mTextReflowStates[i]->mLineLayout;
+    nscoord istart = lineLayout->GetCurrentICoord();
+    lineLayout->ReflowFrame(rtFrame, reflowStatus, nullptr, pushedFrame);
     MOZ_ASSERT(!NS_INLINE_IS_BREAK(reflowStatus) && !pushedFrame,
                "Any line break inside ruby box should has been suppressed");
-    spanISize = std::max(spanISize, metrics.ISize(lineWM));
+    nscoord isize = lineLayout->GetCurrentICoord() - istart;
+    spanISize = std::max(spanISize, isize);
   }
 
   return spanISize;
 }