2014-07-22 19:08:01 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code is subject to the terms of the Mozilla Public License
|
|
|
|
* version 2.0 (the "License"). You can obtain a copy of the License at
|
|
|
|
* http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/* rendering object for CSS "display: ruby" */
|
2015-03-26 00:29:31 -07:00
|
|
|
|
2014-07-22 19:08:01 -07:00
|
|
|
#include "nsRubyFrame.h"
|
2015-03-26 00:29:31 -07:00
|
|
|
|
|
|
|
#include "RubyUtils.h"
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
#include "mozilla/WritingModes.h"
|
2014-08-15 10:34:20 -07:00
|
|
|
#include "nsLineLayout.h"
|
2014-07-22 19:08:01 -07:00
|
|
|
#include "nsPresContext.h"
|
2014-08-15 10:34:20 -07:00
|
|
|
#include "nsRubyBaseContainerFrame.h"
|
|
|
|
#include "nsRubyTextContainerFrame.h"
|
2015-03-26 00:29:31 -07:00
|
|
|
#include "nsStyleContext.h"
|
2014-08-15 10:34:20 -07:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2014-07-22 19:08:01 -07:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Frame class boilerplate
|
|
|
|
// =======================
|
|
|
|
|
|
|
|
NS_QUERYFRAME_HEAD(nsRubyFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsRubyFrame)
|
2015-01-15 01:02:11 -08:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsRubyFrameSuper)
|
2014-07-22 19:08:01 -07:00
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsRubyFrame)
|
|
|
|
|
|
|
|
nsContainerFrame*
|
|
|
|
NS_NewRubyFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsRubyFrame(aContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// nsRubyFrame Method Implementations
|
|
|
|
// ==================================
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsRubyFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::rubyFrame;
|
|
|
|
}
|
|
|
|
|
2014-08-15 10:34:20 -07:00
|
|
|
/* virtual */ bool
|
2014-07-22 19:08:01 -07:00
|
|
|
nsRubyFrame::IsFrameOfType(uint32_t aFlags) const
|
|
|
|
{
|
2015-01-15 01:02:11 -08:00
|
|
|
if (aFlags & eBidiInlineContainer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return nsRubyFrameSuper::IsFrameOfType(aFlags);
|
2014-07-22 19:08:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
|
|
nsresult
|
|
|
|
nsRubyFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Ruby"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-15 10:34:20 -07:00
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsRubyFrame::AddInlineMinISize(nsRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame::InlineMinISizeData *aData)
|
|
|
|
{
|
2015-02-21 03:39:33 -08:00
|
|
|
for (nsIFrame* frame = this; frame; frame = frame->GetNextInFlow()) {
|
2015-04-07 16:22:34 -07:00
|
|
|
for (RubySegmentEnumerator e(static_cast<nsRubyFrame*>(frame));
|
2015-02-21 03:39:33 -08:00
|
|
|
!e.AtEnd(); e.Next()) {
|
|
|
|
e.GetBaseContainer()->AddInlineMinISize(aRenderingContext, aData);
|
|
|
|
}
|
2014-08-15 10:34:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsRubyFrame::AddInlinePrefISize(nsRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame::InlinePrefISizeData *aData)
|
|
|
|
{
|
2015-02-21 03:39:33 -08:00
|
|
|
for (nsIFrame* frame = this; frame; frame = frame->GetNextInFlow()) {
|
2015-04-07 16:22:34 -07:00
|
|
|
for (RubySegmentEnumerator e(static_cast<nsRubyFrame*>(frame));
|
2015-02-21 03:39:33 -08:00
|
|
|
!e.AtEnd(); e.Next()) {
|
|
|
|
e.GetBaseContainer()->AddInlinePrefISize(aRenderingContext, aData);
|
|
|
|
}
|
2014-08-15 10:34:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsRubyFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2015-03-29 15:38:40 -07:00
|
|
|
MarkInReflow();
|
2014-08-15 10:34:20 -07:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsRubyFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
|
|
|
|
|
|
|
if (!aReflowState.mLineLayout) {
|
|
|
|
NS_ASSERTION(aReflowState.mLineLayout,
|
|
|
|
"No line layout provided to RubyFrame reflow method.");
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-25 20:52:50 -08:00
|
|
|
// Grab overflow frames from prev-in-flow and its own.
|
|
|
|
MoveOverflowToChildList();
|
|
|
|
|
2015-01-07 21:02:41 -08:00
|
|
|
// Clear leadings
|
|
|
|
mBStartLeading = mBEndLeading = 0;
|
|
|
|
|
2014-08-15 10:34:20 -07:00
|
|
|
// Begin the span for the ruby frame
|
|
|
|
WritingMode frameWM = aReflowState.GetWritingMode();
|
|
|
|
WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
|
|
|
|
LogicalMargin borderPadding = aReflowState.ComputedLogicalBorderPadding();
|
2015-01-15 01:02:11 -08:00
|
|
|
nscoord startEdge = 0;
|
|
|
|
const bool boxDecorationBreakClone =
|
|
|
|
StyleBorder()->mBoxDecorationBreak == NS_STYLE_BOX_DECORATION_BREAK_CLONE;
|
|
|
|
if (boxDecorationBreakClone || !GetPrevContinuation()) {
|
|
|
|
startEdge = borderPadding.IStart(frameWM);
|
|
|
|
}
|
2014-11-25 20:52:49 -08:00
|
|
|
NS_ASSERTION(aReflowState.AvailableISize() != NS_UNCONSTRAINEDSIZE,
|
2014-08-15 10:34:20 -07:00
|
|
|
"should no longer use available widths");
|
2015-01-15 01:02:11 -08:00
|
|
|
nscoord availableISize = aReflowState.AvailableISize();
|
|
|
|
availableISize -= startEdge + borderPadding.IEnd(frameWM);
|
2014-08-15 10:34:20 -07:00
|
|
|
aReflowState.mLineLayout->BeginSpan(this, &aReflowState,
|
2015-01-15 01:02:11 -08:00
|
|
|
startEdge, availableISize, &mBaseline);
|
2014-08-15 10:34:20 -07:00
|
|
|
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2015-04-07 16:22:34 -07:00
|
|
|
for (RubySegmentEnumerator e(this); !e.AtEnd(); e.Next()) {
|
2014-11-25 20:52:50 -08:00
|
|
|
ReflowSegment(aPresContext, aReflowState, e.GetBaseContainer(), aStatus);
|
2014-11-25 20:52:50 -08:00
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK(aStatus)) {
|
|
|
|
// A break occurs when reflowing the segment.
|
|
|
|
// Don't continue reflowing more segments.
|
|
|
|
break;
|
|
|
|
}
|
2014-08-15 10:34:20 -07:00
|
|
|
}
|
|
|
|
|
2014-11-25 20:52:50 -08:00
|
|
|
ContinuationTraversingState pullState(this);
|
|
|
|
while (aStatus == NS_FRAME_COMPLETE) {
|
|
|
|
nsRubyBaseContainerFrame* baseContainer = PullOneSegment(pullState);
|
|
|
|
if (!baseContainer) {
|
|
|
|
// No more continuations after, finish now.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ReflowSegment(aPresContext, aReflowState, baseContainer, aStatus);
|
|
|
|
}
|
|
|
|
// We never handle overflow in ruby.
|
|
|
|
MOZ_ASSERT(!NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus));
|
|
|
|
|
2014-08-15 10:34:20 -07:00
|
|
|
aDesiredSize.ISize(lineWM) = aReflowState.mLineLayout->EndSpan(this);
|
2015-01-15 01:02:11 -08:00
|
|
|
if (boxDecorationBreakClone || !GetPrevContinuation()) {
|
|
|
|
aDesiredSize.ISize(lineWM) += borderPadding.IStart(frameWM);
|
|
|
|
}
|
|
|
|
if (boxDecorationBreakClone || NS_FRAME_IS_COMPLETE(aStatus)) {
|
|
|
|
aDesiredSize.ISize(lineWM) += borderPadding.IEnd(frameWM);
|
|
|
|
}
|
|
|
|
|
2015-01-15 01:02:11 -08:00
|
|
|
nsLayoutUtils::SetBSizeFromFontMetrics(this, aDesiredSize,
|
2014-08-15 10:34:20 -07:00
|
|
|
borderPadding, lineWM, frameWM);
|
|
|
|
}
|
2014-11-25 20:52:50 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
nsRubyFrame::ReflowSegment(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsRubyBaseContainerFrame* aBaseContainer,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
|
|
|
|
LogicalSize availSize(lineWM, aReflowState.AvailableISize(),
|
|
|
|
aReflowState.AvailableBSize());
|
2015-04-07 16:22:34 -07:00
|
|
|
WritingMode rubyWM = GetWritingMode();
|
|
|
|
NS_ASSERTION(!rubyWM.IsOrthogonalTo(lineWM),
|
|
|
|
"Ruby frame writing-mode shouldn't be orthogonal to its line");
|
2014-11-25 20:52:50 -08:00
|
|
|
|
2015-04-07 16:22:34 -07:00
|
|
|
AutoRubyTextContainerArray textContainers(aBaseContainer);
|
2014-11-25 20:52:50 -08:00
|
|
|
const uint32_t rtcCount = textContainers.Length();
|
|
|
|
|
2014-11-25 20:52:50 -08:00
|
|
|
nsHTMLReflowMetrics baseMetrics(aReflowState);
|
|
|
|
bool pushedFrame;
|
2014-11-25 20:52:50 -08:00
|
|
|
aReflowState.mLineLayout->ReflowFrame(aBaseContainer, aStatus,
|
2014-11-25 20:52:50 -08:00
|
|
|
&baseMetrics, pushedFrame);
|
|
|
|
|
2014-11-25 20:52:50 -08:00
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(aStatus)) {
|
|
|
|
if (aBaseContainer != mFrames.FirstChild()) {
|
|
|
|
// Some segments may have been reflowed before, hence it is not
|
|
|
|
// a break-before for the ruby container.
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_AFTER(NS_FRAME_NOT_COMPLETE);
|
|
|
|
PushChildren(aBaseContainer, aBaseContainer->GetPrevSibling());
|
|
|
|
aReflowState.mLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
|
|
|
// This base container is not placed at all, we can skip all
|
|
|
|
// text containers paired with it.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
|
|
|
// It always promise that if the status is incomplete, there is a
|
|
|
|
// break occurs. Break before has been processed above. However,
|
|
|
|
// it is possible that break after happens with the frame reflow
|
|
|
|
// completed. It happens if there is a force break at the end.
|
|
|
|
MOZ_ASSERT(NS_INLINE_IS_BREAK_AFTER(aStatus));
|
|
|
|
// Find the previous sibling which we will
|
|
|
|
// insert new continuations after.
|
|
|
|
nsIFrame* lastChild;
|
|
|
|
if (rtcCount > 0) {
|
|
|
|
lastChild = textContainers.LastElement();
|
|
|
|
} else {
|
|
|
|
lastChild = aBaseContainer;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create continuations for the base container
|
2014-12-01 22:03:57 -08:00
|
|
|
nsIFrame* newBaseContainer = CreateNextInFlow(aBaseContainer);
|
2014-11-25 20:52:50 -08:00
|
|
|
// newBaseContainer is null if there are existing next-in-flows.
|
|
|
|
// We only need to move and push if there were not.
|
|
|
|
if (newBaseContainer) {
|
|
|
|
// Move the new frame after all the text containers
|
|
|
|
mFrames.RemoveFrame(newBaseContainer);
|
|
|
|
mFrames.InsertFrame(nullptr, lastChild, newBaseContainer);
|
|
|
|
|
|
|
|
// Create continuations for text containers
|
|
|
|
nsIFrame* newLastChild = newBaseContainer;
|
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-12-01 22:03:57 -08:00
|
|
|
nsIFrame* newTextContainer = CreateNextInFlow(textContainers[i]);
|
2014-11-25 20:52:50 -08:00
|
|
|
MOZ_ASSERT(newTextContainer, "Next-in-flow of rtc should not exist "
|
|
|
|
"if the corresponding rbc does not");
|
|
|
|
mFrames.RemoveFrame(newTextContainer);
|
|
|
|
mFrames.InsertFrame(nullptr, newLastChild, newTextContainer);
|
|
|
|
newLastChild = newTextContainer;
|
|
|
|
}
|
2015-01-06 17:47:09 -08:00
|
|
|
}
|
|
|
|
if (lastChild != mFrames.LastChild()) {
|
|
|
|
// Always push the next frame after the last child in this segment.
|
|
|
|
// It is possible that we pulled it back before our next-in-flow
|
|
|
|
// drain our overflow.
|
|
|
|
PushChildren(lastChild->GetNextSibling(), lastChild);
|
2014-11-25 20:52:50 -08:00
|
|
|
aReflowState.mLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// If the ruby base container is reflowed completely, the line
|
|
|
|
// layout will remove the next-in-flows of that frame. But the
|
|
|
|
// line layout is not aware of the ruby text containers, hence
|
|
|
|
// it is necessary to remove them here.
|
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
|
|
|
nsIFrame* nextRTC = textContainers[i]->GetNextInFlow();
|
|
|
|
if (nextRTC) {
|
|
|
|
nextRTC->GetParent()->DeleteNextInFlowChild(nextRTC, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-06 17:47:09 -08:00
|
|
|
nscoord segmentISize = baseMetrics.ISize(lineWM);
|
2015-03-13 22:46:33 -07:00
|
|
|
LogicalRect baseRect = aBaseContainer->GetLogicalRect(lineWM, 0);
|
2014-12-17 00:42:32 -08:00
|
|
|
// We need to position our rtc frames on one side or the other of the
|
|
|
|
// base container's rect, using a coordinate space that's relative to
|
|
|
|
// the ruby frame. Right now, the base container's rect's block-axis
|
|
|
|
// position is relative to the block container frame containing the
|
|
|
|
// lines, so we use 0 instead. (i.e. we assume that the base container
|
|
|
|
// is adjacent to the ruby frame's block-start edge.)
|
|
|
|
// XXX We may need to add border/padding here. See bug 1055667.
|
2015-03-13 22:46:33 -07:00
|
|
|
baseRect.BStart(lineWM) = 0;
|
2014-12-17 00:42:32 -08:00
|
|
|
// The rect for offsets of text containers.
|
2015-03-13 22:46:33 -07:00
|
|
|
LogicalRect offsetRect = baseRect;
|
2014-11-25 20:52:50 -08:00
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
|
|
|
nsRubyTextContainerFrame* textContainer = textContainers[i];
|
2015-04-07 16:22:34 -07:00
|
|
|
WritingMode rtcWM = textContainer->GetWritingMode();
|
2014-11-25 20:52:50 -08:00
|
|
|
nsReflowStatus textReflowStatus;
|
|
|
|
nsHTMLReflowMetrics textMetrics(aReflowState);
|
2015-04-07 16:22:34 -07:00
|
|
|
nsHTMLReflowState textReflowState(aPresContext, aReflowState, textContainer,
|
|
|
|
availSize.ConvertTo(rtcWM, lineWM));
|
2014-11-25 20:52:50 -08:00
|
|
|
// 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.
|
2014-11-25 20:52:50 -08:00
|
|
|
textReflowState.mLineLayout = aReflowState.mLineLayout;
|
|
|
|
textContainer->Reflow(aPresContext, textMetrics,
|
|
|
|
textReflowState, textReflowStatus);
|
2014-11-25 20:52:50 -08:00
|
|
|
// Ruby text containers always return NS_FRAME_COMPLETE even when
|
|
|
|
// they have continuations, because the breaking has already been
|
|
|
|
// handled when reflowing the base containers.
|
2014-11-25 20:52:50 -08:00
|
|
|
NS_ASSERTION(textReflowStatus == NS_FRAME_COMPLETE,
|
2014-11-25 20:52:50 -08:00
|
|
|
"Ruby text container must not break itself inside");
|
2015-04-07 16:22:34 -07:00
|
|
|
// The metrics is initialized with reflow state of this ruby frame,
|
|
|
|
// hence the writing-mode is tied to rubyWM instead of rtcWM.
|
|
|
|
LogicalSize size = textMetrics.Size(rubyWM).ConvertTo(lineWM, rubyWM);
|
|
|
|
textContainer->SetSize(lineWM, size);
|
2015-01-06 17:47:09 -08:00
|
|
|
|
|
|
|
nscoord reservedISize = RubyUtils::GetReservedISize(textContainer);
|
2015-04-07 16:22:34 -07:00
|
|
|
segmentISize = std::max(segmentISize, size.ISize(lineWM) + reservedISize);
|
2014-12-17 00:42:32 -08:00
|
|
|
|
|
|
|
uint8_t rubyPosition = textContainer->StyleText()->mRubyPosition;
|
2015-01-21 19:04:55 -08:00
|
|
|
MOZ_ASSERT(rubyPosition == NS_STYLE_RUBY_POSITION_OVER ||
|
|
|
|
rubyPosition == NS_STYLE_RUBY_POSITION_UNDER);
|
2015-03-13 22:46:33 -07:00
|
|
|
Maybe<LogicalSide> side;
|
2015-01-21 19:04:55 -08:00
|
|
|
if (rubyPosition == NS_STYLE_RUBY_POSITION_OVER) {
|
2015-03-13 22:46:33 -07:00
|
|
|
side.emplace(lineWM.LogicalSideForLineRelativeDir(eLineRelativeDirOver));
|
2015-01-21 19:04:55 -08:00
|
|
|
} else if (rubyPosition == NS_STYLE_RUBY_POSITION_UNDER) {
|
2015-03-13 22:46:33 -07:00
|
|
|
side.emplace(lineWM.LogicalSideForLineRelativeDir(eLineRelativeDirUnder));
|
2014-11-25 20:52:50 -08:00
|
|
|
} else {
|
2015-01-21 19:04:55 -08:00
|
|
|
// XXX inter-character support in bug 1055672
|
|
|
|
MOZ_ASSERT_UNREACHABLE("Unsupported ruby-position");
|
|
|
|
}
|
|
|
|
|
2015-03-13 22:46:33 -07:00
|
|
|
LogicalPoint position(lineWM);
|
2015-01-21 19:04:55 -08:00
|
|
|
if (side.isSome()) {
|
2015-03-13 22:46:33 -07:00
|
|
|
if (side.value() == eLogicalSideBStart) {
|
2015-04-07 16:22:34 -07:00
|
|
|
offsetRect.BStart(lineWM) -= size.BSize(lineWM);
|
|
|
|
offsetRect.BSize(lineWM) += size.BSize(lineWM);
|
2015-03-13 22:46:33 -07:00
|
|
|
position = offsetRect.Origin(lineWM);
|
|
|
|
} else if (side.value() == eLogicalSideBEnd) {
|
|
|
|
position = offsetRect.Origin(lineWM) +
|
|
|
|
LogicalPoint(lineWM, 0, offsetRect.BSize(lineWM));
|
2015-04-07 16:22:34 -07:00
|
|
|
offsetRect.BSize(lineWM) += size.BSize(lineWM);
|
2015-03-13 22:46:33 -07:00
|
|
|
} else {
|
|
|
|
MOZ_ASSERT_UNREACHABLE("???");
|
2014-12-17 00:42:32 -08:00
|
|
|
}
|
2014-11-25 20:52:50 -08:00
|
|
|
}
|
2015-03-13 22:46:33 -07:00
|
|
|
// Container width is set to zero here. We will fix it in
|
|
|
|
// nsLineLayout after the whole line get reflowed.
|
2014-11-25 20:52:50 -08:00
|
|
|
FinishReflowChild(textContainer, aPresContext, textMetrics,
|
2015-03-13 22:46:33 -07:00
|
|
|
&textReflowState, lineWM, position, 0, 0);
|
2014-11-25 20:52:50 -08:00
|
|
|
}
|
2015-03-13 22:46:33 -07:00
|
|
|
MOZ_ASSERT(baseRect.ISize(lineWM) == offsetRect.ISize(lineWM),
|
2015-01-21 19:04:55 -08:00
|
|
|
"Annotations should only be placed on the block directions");
|
2015-01-06 17:47:09 -08:00
|
|
|
|
|
|
|
nscoord deltaISize = segmentISize - baseMetrics.ISize(lineWM);
|
|
|
|
if (deltaISize <= 0) {
|
|
|
|
RubyUtils::ClearReservedISize(aBaseContainer);
|
|
|
|
} else {
|
|
|
|
RubyUtils::SetReservedISize(aBaseContainer, deltaISize);
|
|
|
|
aReflowState.mLineLayout->AdvanceICoord(deltaISize);
|
|
|
|
}
|
2015-01-07 21:02:41 -08:00
|
|
|
|
|
|
|
// Set block leadings of the base container
|
2015-03-13 22:46:33 -07:00
|
|
|
nscoord startLeading = baseRect.BStart(lineWM) - offsetRect.BStart(lineWM);
|
|
|
|
nscoord endLeading = offsetRect.BEnd(lineWM) - baseRect.BEnd(lineWM);
|
2015-03-30 22:30:29 -07:00
|
|
|
// XXX When bug 765861 gets fixed, this warning should be upgraded.
|
|
|
|
NS_WARN_IF_FALSE(startLeading >= 0 && endLeading >= 0,
|
|
|
|
"Leadings should be non-negative (because adding "
|
|
|
|
"ruby annotation can only increase the size)");
|
2015-03-13 22:46:33 -07:00
|
|
|
mBStartLeading = std::max(mBStartLeading, startLeading);
|
|
|
|
mBEndLeading = std::max(mBEndLeading, endLeading);
|
2014-11-25 20:52:50 -08:00
|
|
|
}
|
2014-11-25 20:52:50 -08:00
|
|
|
|
|
|
|
nsRubyBaseContainerFrame*
|
|
|
|
nsRubyFrame::PullOneSegment(ContinuationTraversingState& aState)
|
|
|
|
{
|
|
|
|
// Pull a ruby base container
|
|
|
|
nsIFrame* baseFrame = PullNextInFlowChild(aState);
|
|
|
|
if (!baseFrame) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(baseFrame->GetType() == nsGkAtoms::rubyBaseContainerFrame);
|
|
|
|
|
|
|
|
// Pull all ruby text containers following the base container
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
while ((nextFrame = GetNextInFlowChild(aState)) != nullptr &&
|
|
|
|
nextFrame->GetType() == nsGkAtoms::rubyTextContainerFrame) {
|
|
|
|
PullNextInFlowChild(aState);
|
|
|
|
}
|
|
|
|
|
|
|
|
return static_cast<nsRubyBaseContainerFrame*>(baseFrame);
|
|
|
|
}
|