Commit 37fed548 authored by Kevin Hsieh's avatar Kevin Hsieh
Browse files

Bug 1395777 (part 1) - Allow rtc to use its own writing mode. r=xidorn

MozReview-Commit-ID: EkYL53YxGQV

--HG--
extra : rebase_source : 956c849389a18524968d1c099db155fbd3630888
parent 90ba07bb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -81,9 +81,9 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
  MOZ_ASSERT(aOuterReflowInput, "aOuterReflowInput must not be null");
  NS_ASSERTION(aFloatManager || aOuterReflowInput->mFrame->IsLetterFrame(),
               "float manager should be present");
  MOZ_ASSERT((!!mBaseLineLayout) ==
              aOuterReflowInput->mFrame->IsRubyTextContainerFrame(),
             "Only ruby text container frames have "
  MOZ_ASSERT(aOuterReflowInput->mFrame->IsRubyTextContainerFrame() ||
             !mBaseLineLayout,
             "Only ruby text container frames may have "
             "a different base line layout");
  MOZ_COUNT_CTOR(nsLineLayout);

+10 −4
Original line number Diff line number Diff line
@@ -341,6 +341,10 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext,
  bool hasSpan = false;
  for (uint32_t i = 0; i < rtcCount; i++) {
    nsRubyTextContainerFrame* textContainer = textContainers[i];
    WritingMode rtcWM = textContainer->GetWritingMode();
    nsLineLayout* baseLineLayout =
        lineWM.IsOrthogonalTo(rtcWM) ? nullptr : aReflowInput.mLineLayout;
        // Don't attach a base line layout in the inter-character case.
    if (textContainer->IsSpanContainer()) {
      hasSpan = true;
    }
@@ -352,7 +356,7 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext,
    nsLineLayout* lineLayout = new nsLineLayout(aPresContext,
                                                reflowInput->mFloatManager,
                                                reflowInput, nullptr,
                                                aReflowInput.mLineLayout);
                                                baseLineLayout);
    lineLayout->SetSuppressLineWrap(true);
    lineLayouts.AppendElement(lineLayout);

@@ -367,10 +371,12 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext,
    // rt frames will be updated when reflowing this text container,
    // hence leave container size 0 here for now.
    lineLayout->BeginLineReflow(0, 0, reflowInput->ComputedISize(),
                                NS_UNCONSTRAINEDSIZE,
                                false, false, lineWM, nsSize(0, 0));
                                NS_UNCONSTRAINEDSIZE, false, false,
                                baseLineLayout ? lineWM : rtcWM, nsSize(0, 0));
    if (baseLineLayout) {
      lineLayout->AttachRootFrameToBaseLineLayout();
    }
  }

  aReflowInput.mLineLayout->BeginSpan(this, &aReflowInput,
                                      0, aReflowInput.AvailableISize(),
+0 −5
Original line number Diff line number Diff line
@@ -315,11 +315,6 @@ nsRubyFrame::ReflowSegment(nsPresContext* aPresContext,
    ReflowOutput textMetrics(aReflowInput);
    ReflowInput textReflowInput(aPresContext, aReflowInput, textContainer,
                                      availSize.ConvertTo(rtcWM, lineWM));
    // FIXME We probably shouldn't be using the same nsLineLayout for
    //       the text containers. But it should be fine now as we are
    //       not actually using this line layout to reflow something,
    //       but just read the writing mode from it.
    textReflowInput.mLineLayout = aReflowInput.mLineLayout;
    textContainer->Reflow(aPresContext, textMetrics,
                          textReflowInput, textReflowStatus);
    // Ruby text containers always return complete reflow status even when
+12 −12
Original line number Diff line number Diff line
@@ -128,7 +128,7 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext,
  // ignores the status, and continuations of the ruby base container
  // will take care of our continuations.
  aStatus.Reset();
  WritingMode lineWM = aReflowInput.mLineLayout->GetWritingMode();
  WritingMode rtcWM = GetWritingMode();

  nscoord minBCoord = nscoord_MAX;
  nscoord maxBCoord = nscoord_MIN;
@@ -139,37 +139,37 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext,
  for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
    nsIFrame* child = e.get();
    MOZ_ASSERT(child->IsRubyTextFrame());
    LogicalRect rect = child->GetLogicalRect(lineWM, dummyContainerSize);
    LogicalMargin margin = child->GetLogicalUsedMargin(lineWM);
    nscoord blockStart = rect.BStart(lineWM) - margin.BStart(lineWM);
    LogicalRect rect = child->GetLogicalRect(rtcWM, dummyContainerSize);
    LogicalMargin margin = child->GetLogicalUsedMargin(rtcWM);
    nscoord blockStart = rect.BStart(rtcWM) - margin.BStart(rtcWM);
    minBCoord = std::min(minBCoord, blockStart);
    nscoord blockEnd = rect.BEnd(lineWM) + margin.BEnd(lineWM);
    nscoord blockEnd = rect.BEnd(rtcWM) + margin.BEnd(rtcWM);
    maxBCoord = std::max(maxBCoord, blockEnd);
  }

  LogicalSize size(lineWM, mISize, 0);
  LogicalSize size(rtcWM, mISize, 0);
  if (!mFrames.IsEmpty()) {
    if (MOZ_UNLIKELY(minBCoord > maxBCoord)) {
      // XXX When bug 765861 gets fixed, this warning should be upgraded.
      NS_WARNING("bad block coord");
      minBCoord = maxBCoord = 0;
    }
    size.BSize(lineWM) = maxBCoord - minBCoord;
    nsSize containerSize = size.GetPhysicalSize(lineWM);
    size.BSize(rtcWM) = maxBCoord - minBCoord;
    nsSize containerSize = size.GetPhysicalSize(rtcWM);
    for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
      nsIFrame* child = e.get();
      // We reflowed the child with a dummy container size, as the true size
      // was not yet known at that time.
      LogicalPoint pos = child->GetLogicalPosition(lineWM, dummyContainerSize);
      LogicalPoint pos = child->GetLogicalPosition(rtcWM, dummyContainerSize);
      // Adjust block position to account for minBCoord,
      // then reposition child based on the true container width.
      pos.B(lineWM) -= minBCoord;
      pos.B(rtcWM) -= minBCoord;
      // Relative positioning hasn't happened yet.
      // So MovePositionBy should not be used here.
      child->SetPosition(lineWM, pos, containerSize);
      child->SetPosition(rtcWM, pos, containerSize);
      nsContainerFrame::PlaceFrameView(child);
    }
  }

  aDesiredSize.SetSize(lineWM, size);
  aDesiredSize.SetSize(rtcWM, size);
}