2014-07-23 06:08:01 +04: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-base-container" */
|
|
|
|
|
|
|
|
#include "nsRubyBaseContainerFrame.h"
|
2014-12-15 06:37:15 +03:00
|
|
|
#include "nsContentUtils.h"
|
2014-08-15 21:34:20 +04:00
|
|
|
#include "nsLineLayout.h"
|
2014-07-23 06:08:01 +04:00
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsStyleContext.h"
|
2014-12-22 08:52:30 +03:00
|
|
|
#include "nsStyleStructInlines.h"
|
2014-08-15 21:34:20 +04:00
|
|
|
#include "WritingModes.h"
|
2014-12-13 03:05:02 +03:00
|
|
|
#include "RubyUtils.h"
|
2014-08-15 21:34:20 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2014-07-23 06:08:01 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Frame class boilerplate
|
|
|
|
// =======================
|
|
|
|
|
|
|
|
NS_QUERYFRAME_HEAD(nsRubyBaseContainerFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsRubyBaseContainerFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
|
|
|
|
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsRubyBaseContainerFrame)
|
|
|
|
|
|
|
|
nsContainerFrame*
|
|
|
|
NS_NewRubyBaseContainerFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsRubyBaseContainerFrame(aContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// nsRubyBaseContainerFrame Method Implementations
|
|
|
|
// ===============================================
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsRubyBaseContainerFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::rubyBaseContainerFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
|
|
|
nsresult
|
|
|
|
nsRubyBaseContainerFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("RubyBaseContainer"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
2014-08-15 21:34:20 +04:00
|
|
|
|
2014-12-29 06:30:00 +03:00
|
|
|
/**
|
|
|
|
* Ruby column is a unit consists of one ruby base and all ruby
|
|
|
|
* annotations paired with it.
|
|
|
|
* See http://dev.w3.org/csswg/css-ruby/#ruby-pairing
|
|
|
|
*/
|
2014-12-29 07:22:19 +03:00
|
|
|
struct MOZ_STACK_CLASS mozilla::RubyColumn
|
|
|
|
{
|
|
|
|
nsIFrame* mBaseFrame;
|
|
|
|
nsAutoTArray<nsIFrame*, RTC_ARRAY_SIZE> mTextFrames;
|
|
|
|
RubyColumn() : mBaseFrame(nullptr) { }
|
|
|
|
};
|
|
|
|
|
2014-12-29 06:30:00 +03:00
|
|
|
class MOZ_STACK_CLASS RubyColumnEnumerator
|
2014-11-26 07:52:48 +03:00
|
|
|
{
|
|
|
|
public:
|
2014-12-29 06:30:00 +03:00
|
|
|
RubyColumnEnumerator(nsRubyBaseContainerFrame* aRBCFrame,
|
|
|
|
const nsTArray<nsRubyTextContainerFrame*>& aRTCFrames);
|
2014-11-26 07:52:48 +03:00
|
|
|
|
|
|
|
void Next();
|
|
|
|
bool AtEnd() const;
|
|
|
|
|
|
|
|
uint32_t GetLevelCount() const { return mFrames.Length(); }
|
|
|
|
nsIFrame* GetFrame(uint32_t aIndex) const { return mFrames[aIndex]; }
|
|
|
|
nsIFrame* GetBaseFrame() const { return GetFrame(0); }
|
|
|
|
nsIFrame* GetTextFrame(uint32_t aIndex) const { return GetFrame(aIndex + 1); }
|
2014-12-29 07:22:19 +03:00
|
|
|
void GetColumn(RubyColumn& aColumn) const;
|
2014-11-26 07:52:48 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsAutoTArray<nsIFrame*, RTC_ARRAY_SIZE + 1> mFrames;
|
|
|
|
};
|
|
|
|
|
2014-12-29 06:30:00 +03:00
|
|
|
RubyColumnEnumerator::RubyColumnEnumerator(
|
|
|
|
nsRubyBaseContainerFrame* aBaseContainer,
|
|
|
|
const nsTArray<nsRubyTextContainerFrame*>& aTextContainers)
|
2014-11-26 07:52:48 +03:00
|
|
|
{
|
|
|
|
const uint32_t rtcCount = aTextContainers.Length();
|
|
|
|
mFrames.SetCapacity(rtcCount + 1);
|
|
|
|
mFrames.AppendElement(aBaseContainer->GetFirstPrincipalChild());
|
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-12-30 01:44:12 +03:00
|
|
|
nsRubyTextContainerFrame* container = aTextContainers[i];
|
|
|
|
// If the container is for span, leave a nullptr here.
|
|
|
|
// Spans do not take part in pairing.
|
|
|
|
nsIFrame* rtFrame = !container->IsSpanContainer() ?
|
|
|
|
aTextContainers[i]->GetFirstPrincipalChild() : nullptr;
|
2014-11-26 07:52:48 +03:00
|
|
|
mFrames.AppendElement(rtFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-29 06:30:00 +03:00
|
|
|
RubyColumnEnumerator::Next()
|
2014-11-26 07:52:48 +03:00
|
|
|
{
|
|
|
|
for (uint32_t i = 0, iend = mFrames.Length(); i < iend; i++) {
|
|
|
|
if (mFrames[i]) {
|
|
|
|
mFrames[i] = mFrames[i]->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-12-29 06:30:00 +03:00
|
|
|
RubyColumnEnumerator::AtEnd() const
|
2014-11-26 07:52:48 +03:00
|
|
|
{
|
|
|
|
for (uint32_t i = 0, iend = mFrames.Length(); i < iend; i++) {
|
|
|
|
if (mFrames[i]) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
void
|
2014-12-29 07:22:19 +03:00
|
|
|
RubyColumnEnumerator::GetColumn(RubyColumn& aColumn) const
|
2014-11-26 07:52:50 +03:00
|
|
|
{
|
2014-12-29 07:22:19 +03:00
|
|
|
aColumn.mBaseFrame = mFrames[0];
|
|
|
|
aColumn.mTextFrames.ClearAndRetainStorage();
|
2014-11-26 07:52:50 +03:00
|
|
|
for (uint32_t i = 1, iend = mFrames.Length(); i < iend; i++) {
|
2014-12-29 07:22:19 +03:00
|
|
|
aColumn.mTextFrames.AppendElement(mFrames[i]);
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:48 +03:00
|
|
|
static nscoord
|
2014-12-29 06:30:00 +03:00
|
|
|
CalculateColumnPrefISize(nsRenderingContext* aRenderingContext,
|
|
|
|
const RubyColumnEnumerator& aEnumerator)
|
2014-11-26 07:52:48 +03:00
|
|
|
{
|
|
|
|
nscoord max = 0;
|
|
|
|
uint32_t levelCount = aEnumerator.GetLevelCount();
|
|
|
|
for (uint32_t i = 0; i < levelCount; i++) {
|
|
|
|
nsIFrame* frame = aEnumerator.GetFrame(i);
|
|
|
|
if (frame) {
|
|
|
|
max = std::max(max, frame->GetPrefISize(aRenderingContext));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsRubyBaseContainerFrame::AddInlineMinISize(
|
|
|
|
nsRenderingContext *aRenderingContext, nsIFrame::InlineMinISizeData *aData)
|
|
|
|
{
|
2014-12-30 01:56:34 +03:00
|
|
|
AutoTextContainerArray textContainers;
|
|
|
|
GetTextContainers(textContainers);
|
|
|
|
|
|
|
|
for (uint32_t i = 0, iend = textContainers.Length(); i < iend; i++) {
|
|
|
|
if (textContainers[i]->IsSpanContainer()) {
|
2014-12-30 01:44:12 +03:00
|
|
|
// Since spans are not breakable internally, use our pref isize
|
|
|
|
// directly if there is any span.
|
|
|
|
aData->currentLine += GetPrefISize(aRenderingContext);
|
|
|
|
return;
|
|
|
|
}
|
2014-11-26 07:52:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord max = 0;
|
2014-12-30 01:56:34 +03:00
|
|
|
RubyColumnEnumerator enumerator(this, textContainers);
|
2014-11-26 07:52:48 +03:00
|
|
|
for (; !enumerator.AtEnd(); enumerator.Next()) {
|
2014-12-29 06:30:00 +03:00
|
|
|
// We use *pref* isize for computing the min isize of columns
|
2014-11-26 07:52:48 +03:00
|
|
|
// because ruby bases and texts are unbreakable internally.
|
2014-12-29 06:30:00 +03:00
|
|
|
max = std::max(max, CalculateColumnPrefISize(aRenderingContext,
|
|
|
|
enumerator));
|
2014-11-26 07:52:48 +03:00
|
|
|
}
|
|
|
|
aData->currentLine += max;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ void
|
|
|
|
nsRubyBaseContainerFrame::AddInlinePrefISize(
|
|
|
|
nsRenderingContext *aRenderingContext, nsIFrame::InlinePrefISizeData *aData)
|
|
|
|
{
|
2014-12-30 01:56:34 +03:00
|
|
|
AutoTextContainerArray textContainers;
|
|
|
|
GetTextContainers(textContainers);
|
|
|
|
|
2014-11-26 07:52:48 +03:00
|
|
|
nscoord sum = 0;
|
2014-12-30 01:56:34 +03:00
|
|
|
RubyColumnEnumerator enumerator(this, textContainers);
|
2014-11-26 07:52:48 +03:00
|
|
|
for (; !enumerator.AtEnd(); enumerator.Next()) {
|
2014-12-29 06:30:00 +03:00
|
|
|
sum += CalculateColumnPrefISize(aRenderingContext, enumerator);
|
2014-11-26 07:52:48 +03:00
|
|
|
}
|
2014-12-30 01:56:34 +03:00
|
|
|
for (uint32_t i = 0, iend = textContainers.Length(); i < iend; i++) {
|
|
|
|
if (textContainers[i]->IsSpanContainer()) {
|
|
|
|
nsIFrame* frame = textContainers[i]->GetFirstPrincipalChild();
|
2014-12-30 01:44:12 +03:00
|
|
|
sum = std::max(sum, frame->GetPrefISize(aRenderingContext));
|
|
|
|
}
|
|
|
|
}
|
2014-11-26 07:52:48 +03:00
|
|
|
aData->currentLine += sum;
|
|
|
|
}
|
|
|
|
|
2014-08-15 21:34:20 +04:00
|
|
|
/* virtual */ bool
|
|
|
|
nsRubyBaseContainerFrame::IsFrameOfType(uint32_t aFlags) const
|
|
|
|
{
|
|
|
|
return nsContainerFrame::IsFrameOfType(aFlags &
|
|
|
|
~(nsIFrame::eLineParticipant));
|
|
|
|
}
|
2014-08-15 21:34:20 +04:00
|
|
|
|
2014-12-30 01:56:34 +03:00
|
|
|
void
|
|
|
|
nsRubyBaseContainerFrame::GetTextContainers(TextContainerArray& aTextContainers)
|
2014-08-15 21:34:20 +04:00
|
|
|
{
|
2014-12-30 01:56:34 +03:00
|
|
|
MOZ_ASSERT(aTextContainers.IsEmpty());
|
|
|
|
for (RubyTextContainerIterator iter(this); !iter.AtEnd(); iter.Next()) {
|
|
|
|
aTextContainers.AppendElement(iter.GetTextContainer());
|
|
|
|
}
|
2014-08-15 21:34:20 +04:00
|
|
|
}
|
|
|
|
|
2014-08-15 21:34:20 +04:00
|
|
|
/* virtual */ bool
|
|
|
|
nsRubyBaseContainerFrame::CanContinueTextRun() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:49 +03:00
|
|
|
/* virtual */ LogicalSize
|
|
|
|
nsRubyBaseContainerFrame::ComputeSize(nsRenderingContext *aRenderingContext,
|
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalSize& aCBSize,
|
|
|
|
nscoord aAvailableISize,
|
|
|
|
const LogicalSize& aMargin,
|
|
|
|
const LogicalSize& aBorder,
|
|
|
|
const LogicalSize& aPadding,
|
|
|
|
ComputeSizeFlags aFlags)
|
|
|
|
{
|
|
|
|
// Ruby base container frame is inline,
|
|
|
|
// hence don't compute size before reflow.
|
|
|
|
return LogicalSize(aWM, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:49 +03:00
|
|
|
/* virtual */ nscoord
|
|
|
|
nsRubyBaseContainerFrame::GetLogicalBaseline(WritingMode aWritingMode) const
|
|
|
|
{
|
|
|
|
return mBaseline;
|
|
|
|
}
|
|
|
|
|
2014-12-29 07:03:38 +03:00
|
|
|
struct nsRubyBaseContainerFrame::ReflowState
|
|
|
|
{
|
|
|
|
bool mAllowLineBreak;
|
2014-12-30 01:56:34 +03:00
|
|
|
const TextContainerArray& mTextContainers;
|
2014-12-29 07:03:38 +03:00
|
|
|
const nsHTMLReflowState& mBaseReflowState;
|
2014-12-30 01:44:12 +03:00
|
|
|
const nsTArray<UniquePtr<nsHTMLReflowState>>& mTextReflowStates;
|
2014-12-29 07:03:38 +03:00
|
|
|
};
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
// Check whether the given extra isize can fit in the line in base level.
|
|
|
|
static bool
|
|
|
|
ShouldBreakBefore(const nsHTMLReflowState& aReflowState, nscoord aExtraISize)
|
|
|
|
{
|
|
|
|
nsLineLayout* lineLayout = aReflowState.mLineLayout;
|
|
|
|
int32_t offset;
|
|
|
|
gfxBreakPriority priority;
|
|
|
|
nscoord icoord = lineLayout->GetCurrentICoord();
|
|
|
|
return icoord + aExtraISize > aReflowState.AvailableISize() &&
|
|
|
|
lineLayout->GetLastOptionalBreakPosition(&offset, &priority);
|
|
|
|
}
|
|
|
|
|
2014-08-15 21:34:20 +04:00
|
|
|
/* virtual */ void
|
|
|
|
nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsRubyBaseContainerFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2014-12-22 08:24:24 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2014-08-15 21:34:20 +04:00
|
|
|
|
|
|
|
if (!aReflowState.mLineLayout) {
|
|
|
|
NS_ASSERTION(
|
|
|
|
aReflowState.mLineLayout,
|
|
|
|
"No line layout provided to RubyBaseContainerFrame reflow method.");
|
|
|
|
return;
|
|
|
|
}
|
2014-12-30 03:16:30 +03:00
|
|
|
MOZ_ASSERT(aReflowState.mRubyReflowState, "No ruby reflow state provided");
|
2014-08-15 21:34:20 +04:00
|
|
|
|
2014-12-30 01:56:34 +03:00
|
|
|
AutoTextContainerArray textContainers;
|
|
|
|
GetTextContainers(textContainers);
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
MoveOverflowToChildList();
|
|
|
|
// Ask text containers to drain overflows
|
2014-12-30 01:56:34 +03:00
|
|
|
const uint32_t rtcCount = textContainers.Length();
|
2014-11-26 07:52:50 +03:00
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-12-30 01:56:34 +03:00
|
|
|
textContainers[i]->MoveOverflowToChildList();
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
|
2014-08-15 21:34:20 +04:00
|
|
|
WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
|
|
|
|
LogicalSize availSize(lineWM, aReflowState.AvailableWidth(),
|
|
|
|
aReflowState.AvailableHeight());
|
|
|
|
|
2014-11-26 07:52:49 +03:00
|
|
|
// We have a reflow state and a line layout for each RTC.
|
|
|
|
// They are conceptually the state of the RTCs, but we don't actually
|
|
|
|
// reflow those RTCs in this code. These two arrays are holders of
|
|
|
|
// the reflow states and line layouts.
|
2014-12-11 03:24:53 +03:00
|
|
|
// Since there are pointers refer to reflow states and line layouts,
|
|
|
|
// it is necessary to guarantee that they won't be moved. For this
|
|
|
|
// reason, they are wrapped in UniquePtr here.
|
2014-11-26 07:52:49 +03:00
|
|
|
nsAutoTArray<UniquePtr<nsHTMLReflowState>, RTC_ARRAY_SIZE> reflowStates;
|
|
|
|
nsAutoTArray<UniquePtr<nsLineLayout>, RTC_ARRAY_SIZE> lineLayouts;
|
2014-12-30 01:44:12 +03:00
|
|
|
reflowStates.SetCapacity(rtcCount);
|
|
|
|
lineLayouts.SetCapacity(rtcCount);
|
2014-11-26 07:52:49 +03:00
|
|
|
|
2014-08-15 21:34:20 +04:00
|
|
|
// Begin the line layout for each ruby text container in advance.
|
2014-12-30 01:44:12 +03:00
|
|
|
bool hasSpan = false;
|
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-12-30 01:56:34 +03:00
|
|
|
nsRubyTextContainerFrame* textContainer = textContainers[i];
|
2014-12-30 01:44:12 +03:00
|
|
|
if (textContainer->IsSpanContainer()) {
|
|
|
|
hasSpan = true;
|
2014-11-26 07:52:49 +03:00
|
|
|
}
|
2014-12-30 01:44:12 +03:00
|
|
|
|
2014-11-26 07:52:49 +03:00
|
|
|
nsHTMLReflowState* reflowState = new nsHTMLReflowState(
|
|
|
|
aPresContext, *aReflowState.parentReflowState, textContainer, availSize);
|
|
|
|
reflowStates.AppendElement(reflowState);
|
2014-12-10 02:04:15 +03:00
|
|
|
nsLineLayout* lineLayout = new nsLineLayout(aPresContext,
|
|
|
|
reflowState->mFloatManager,
|
|
|
|
reflowState, nullptr,
|
|
|
|
aReflowState.mLineLayout);
|
2014-11-26 07:52:49 +03:00
|
|
|
lineLayouts.AppendElement(lineLayout);
|
|
|
|
|
|
|
|
// Line number is useless for ruby text
|
|
|
|
// XXX nullptr here may cause problem, see comments for
|
|
|
|
// nsLineLayout::mBlockRS and nsLineLayout::AddFloat
|
|
|
|
lineLayout->Init(nullptr, reflowState->CalcLineHeight(), -1);
|
|
|
|
reflowState->mLineLayout = lineLayout;
|
|
|
|
|
|
|
|
LogicalMargin borderPadding = reflowState->ComputedLogicalBorderPadding();
|
|
|
|
nscoord containerWidth =
|
|
|
|
reflowState->ComputedWidth() + borderPadding.LeftRight(lineWM);
|
|
|
|
|
|
|
|
lineLayout->BeginLineReflow(borderPadding.IStart(lineWM),
|
|
|
|
borderPadding.BStart(lineWM),
|
|
|
|
reflowState->ComputedISize(),
|
|
|
|
NS_UNCONSTRAINEDSIZE,
|
|
|
|
false, false, lineWM, containerWidth);
|
2014-12-10 02:04:15 +03:00
|
|
|
lineLayout->AttachRootFrameToBaseLineLayout();
|
2014-08-15 21:34:20 +04:00
|
|
|
}
|
|
|
|
|
2014-12-11 07:13:42 +03:00
|
|
|
WritingMode frameWM = aReflowState.GetWritingMode();
|
|
|
|
LogicalMargin borderPadding = aReflowState.ComputedLogicalBorderPadding();
|
|
|
|
nscoord startEdge = borderPadding.IStart(frameWM);
|
|
|
|
nscoord endEdge = aReflowState.AvailableISize() - borderPadding.IEnd(frameWM);
|
|
|
|
aReflowState.mLineLayout->BeginSpan(this, &aReflowState,
|
|
|
|
startEdge, endEdge, &mBaseline);
|
|
|
|
|
2014-12-22 08:52:30 +03:00
|
|
|
nsIFrame* parent = GetParent();
|
2014-12-31 08:39:43 +03:00
|
|
|
bool inNestedRuby = parent->StyleContext()->IsInlineDescendantOfRuby();
|
2014-12-22 08:52:30 +03:00
|
|
|
// Allow line break between ruby bases when white-space allows,
|
|
|
|
// we are not inside a nested ruby, and there is no span.
|
|
|
|
bool allowLineBreak = !inNestedRuby && StyleText()->WhiteSpaceCanWrap(this);
|
|
|
|
bool allowInitialLineBreak = allowLineBreak;
|
|
|
|
if (!GetPrevInFlow()) {
|
|
|
|
allowInitialLineBreak = !inNestedRuby &&
|
|
|
|
parent->StyleText()->WhiteSpaceCanWrap(parent);
|
|
|
|
}
|
|
|
|
if (allowInitialLineBreak && aReflowState.mLineLayout->LineIsBreakable() &&
|
2014-12-22 08:24:24 +03:00
|
|
|
aReflowState.mLineLayout->NotifyOptionalBreakPosition(
|
|
|
|
this, 0, startEdge <= aReflowState.AvailableISize(),
|
|
|
|
gfxBreakPriority::eNormalBreak)) {
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord isize = 0;
|
|
|
|
if (aStatus == NS_FRAME_COMPLETE) {
|
2014-12-29 06:30:00 +03:00
|
|
|
// Reflow columns excluding any span
|
2014-12-29 07:03:38 +03:00
|
|
|
ReflowState reflowState = {
|
2014-12-30 01:56:34 +03:00
|
|
|
allowLineBreak && !hasSpan, textContainers, aReflowState, reflowStates
|
2014-12-29 07:03:38 +03:00
|
|
|
};
|
|
|
|
isize = ReflowColumns(reflowState, aStatus);
|
2014-12-22 08:24:24 +03:00
|
|
|
}
|
2014-11-26 07:52:50 +03:00
|
|
|
|
2014-12-29 06:30:00 +03:00
|
|
|
// If there exists any span, the columns must either be completely
|
2014-11-26 07:52:50 +03:00
|
|
|
// reflowed, or be not reflowed at all.
|
|
|
|
MOZ_ASSERT(NS_INLINE_IS_BREAK_BEFORE(aStatus) ||
|
2014-12-30 01:44:12 +03:00
|
|
|
NS_FRAME_IS_COMPLETE(aStatus) || !hasSpan);
|
2014-11-26 07:52:50 +03:00
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(aStatus) &&
|
2014-12-30 01:44:12 +03:00
|
|
|
NS_FRAME_IS_COMPLETE(aStatus) && hasSpan) {
|
2014-11-26 07:52:50 +03:00
|
|
|
// Reflow spans
|
2014-12-29 07:03:38 +03:00
|
|
|
ReflowState reflowState = {
|
2014-12-30 01:56:34 +03:00
|
|
|
false, textContainers, aReflowState, reflowStates
|
2014-12-29 07:03:38 +03:00
|
|
|
};
|
|
|
|
nscoord spanISize = ReflowSpans(reflowState);
|
2014-12-13 03:05:02 +03:00
|
|
|
nscoord deltaISize = spanISize - isize;
|
|
|
|
if (deltaISize <= 0) {
|
|
|
|
RubyUtils::ClearReservedISize(this);
|
|
|
|
} else if (allowLineBreak && ShouldBreakBefore(aReflowState, deltaISize)) {
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
} else {
|
|
|
|
RubyUtils::SetReservedISize(this, deltaISize);
|
|
|
|
aReflowState.mLineLayout->AdvanceICoord(deltaISize);
|
|
|
|
isize = spanISize;
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
2014-12-29 06:30:00 +03:00
|
|
|
// When there are spans, ReflowColumns and ReflowOneColumn won't
|
2014-12-22 08:36:55 +03:00
|
|
|
// record any optional break position. We have to record one
|
|
|
|
// at the end of this segment.
|
2014-12-22 08:52:30 +03:00
|
|
|
if (!NS_INLINE_IS_BREAK(aStatus) && allowLineBreak &&
|
|
|
|
aReflowState.mLineLayout->NotifyOptionalBreakPosition(
|
2014-12-22 08:36:55 +03:00
|
|
|
this, INT32_MAX, startEdge + isize <= aReflowState.AvailableISize(),
|
|
|
|
gfxBreakPriority::eNormalBreak)) {
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_AFTER(aStatus);
|
|
|
|
}
|
2014-12-30 01:24:57 +03:00
|
|
|
}
|
2014-11-26 07:52:50 +03:00
|
|
|
|
|
|
|
DebugOnly<nscoord> lineSpanSize = aReflowState.mLineLayout->EndSpan(this);
|
|
|
|
// When there are no frames inside the ruby base container, EndSpan
|
|
|
|
// will return 0. However, in this case, the actual width of the
|
|
|
|
// container could be non-zero because of non-empty ruby annotations.
|
2014-11-26 07:52:50 +03:00
|
|
|
MOZ_ASSERT(NS_INLINE_IS_BREAK_BEFORE(aStatus) ||
|
|
|
|
isize == lineSpanSize || mFrames.IsEmpty());
|
2014-12-30 01:44:12 +03:00
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-11-26 07:52:50 +03:00
|
|
|
// It happens before the ruby text container is reflowed, and that
|
|
|
|
// when it is reflowed, it will just use this size.
|
2014-12-30 01:56:34 +03:00
|
|
|
nsRubyTextContainerFrame* textContainer = textContainers[i];
|
2014-12-09 09:47:26 +03:00
|
|
|
nsLineLayout* lineLayout = lineLayouts[i].get();
|
2014-12-13 03:05:02 +03:00
|
|
|
|
2014-12-09 09:47:26 +03:00
|
|
|
RubyUtils::ClearReservedISize(textContainer);
|
|
|
|
nscoord rtcISize = lineLayout->GetCurrentICoord();
|
2014-12-13 03:05:02 +03:00
|
|
|
// Only span containers and containers with collapsed annotations
|
|
|
|
// need reserving isize. For normal ruby text containers, their
|
|
|
|
// children will be expanded properly. We only need to expand their
|
|
|
|
// own size.
|
2014-12-30 01:44:12 +03:00
|
|
|
if (!textContainer->IsSpanContainer()) {
|
2014-12-13 03:05:02 +03:00
|
|
|
rtcISize = isize;
|
|
|
|
} else if (isize > rtcISize) {
|
|
|
|
RubyUtils::SetReservedISize(textContainer, isize - rtcISize);
|
|
|
|
}
|
2014-12-09 09:47:26 +03:00
|
|
|
|
|
|
|
lineLayout->VerticalAlignLine();
|
|
|
|
LogicalSize lineSize(lineWM, isize, lineLayout->GetFinalLineBSize());
|
2014-12-30 03:20:10 +03:00
|
|
|
aReflowState.mRubyReflowState->SetTextContainerInfo(i, textContainer, lineSize);
|
2014-12-09 09:47:26 +03:00
|
|
|
lineLayout->EndLineReflow();
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
aDesiredSize.ISize(lineWM) = isize;
|
|
|
|
nsLayoutUtils::SetBSizeFromFontMetrics(this, aDesiredSize, aReflowState,
|
|
|
|
borderPadding, lineWM, frameWM);
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
/**
|
|
|
|
* This struct stores the continuations after this frame and
|
|
|
|
* corresponding text containers. It is used to speed up looking
|
|
|
|
* ahead for nonempty continuations.
|
|
|
|
*/
|
|
|
|
struct MOZ_STACK_CLASS nsRubyBaseContainerFrame::PullFrameState
|
|
|
|
{
|
|
|
|
ContinuationTraversingState mBase;
|
|
|
|
nsAutoTArray<ContinuationTraversingState, RTC_ARRAY_SIZE> mTexts;
|
2014-12-30 01:56:34 +03:00
|
|
|
const TextContainerArray& mTextContainers;
|
2014-11-26 07:52:50 +03:00
|
|
|
|
2014-12-30 01:56:34 +03:00
|
|
|
PullFrameState(nsRubyBaseContainerFrame* aBaseContainer,
|
|
|
|
const TextContainerArray& aTextContainers);
|
2014-11-26 07:52:50 +03:00
|
|
|
};
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
nscoord
|
2014-12-29 07:03:38 +03:00
|
|
|
nsRubyBaseContainerFrame::ReflowColumns(const ReflowState& aReflowState,
|
2014-12-29 06:30:00 +03:00
|
|
|
nsReflowStatus& aStatus)
|
2014-11-26 07:52:50 +03:00
|
|
|
{
|
2014-12-29 07:03:38 +03:00
|
|
|
nsLineLayout* lineLayout = aReflowState.mBaseReflowState.mLineLayout;
|
2014-12-30 01:56:34 +03:00
|
|
|
const uint32_t rtcCount = aReflowState.mTextContainers.Length();
|
2014-11-26 07:52:50 +03:00
|
|
|
nscoord istart = lineLayout->GetCurrentICoord();
|
2014-11-26 07:52:49 +03:00
|
|
|
nscoord icoord = istart;
|
2014-11-26 07:52:50 +03:00
|
|
|
nsReflowStatus reflowStatus = NS_FRAME_COMPLETE;
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2014-11-26 07:52:49 +03:00
|
|
|
|
2014-12-30 02:05:54 +03:00
|
|
|
uint32_t columnIndex = 0;
|
2014-12-29 07:22:19 +03:00
|
|
|
RubyColumn column;
|
|
|
|
column.mTextFrames.SetCapacity(rtcCount);
|
2014-12-30 01:56:34 +03:00
|
|
|
RubyColumnEnumerator e(this, aReflowState.mTextContainers);
|
2014-11-26 07:52:50 +03:00
|
|
|
for (; !e.AtEnd(); e.Next()) {
|
2014-12-29 07:22:19 +03:00
|
|
|
e.GetColumn(column);
|
2014-12-30 02:05:54 +03:00
|
|
|
icoord += ReflowOneColumn(aReflowState, columnIndex, column, reflowStatus);
|
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(reflowStatus)) {
|
|
|
|
columnIndex++;
|
|
|
|
}
|
2014-11-26 07:52:50 +03:00
|
|
|
if (NS_INLINE_IS_BREAK(reflowStatus)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// We are not handling overflow here.
|
|
|
|
MOZ_ASSERT(reflowStatus == NS_FRAME_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isComplete = false;
|
2014-12-30 01:56:34 +03:00
|
|
|
PullFrameState pullFrameState(this, aReflowState.mTextContainers);
|
2014-11-26 07:52:50 +03:00
|
|
|
while (!NS_INLINE_IS_BREAK(reflowStatus)) {
|
|
|
|
// We are not handling overflow here.
|
|
|
|
MOZ_ASSERT(reflowStatus == NS_FRAME_COMPLETE);
|
|
|
|
|
|
|
|
// Try pull some frames from next continuations. This call replaces
|
2014-12-29 07:22:19 +03:00
|
|
|
// frames in |column| with the frame pulled in each level.
|
|
|
|
PullOneColumn(lineLayout, pullFrameState, column, isComplete);
|
2014-11-26 07:52:50 +03:00
|
|
|
if (isComplete) {
|
|
|
|
// No more frames can be pulled.
|
|
|
|
break;
|
|
|
|
}
|
2014-12-30 02:05:54 +03:00
|
|
|
icoord += ReflowOneColumn(aReflowState, columnIndex, column, reflowStatus);
|
|
|
|
if (!NS_INLINE_IS_BREAK_BEFORE(reflowStatus)) {
|
|
|
|
columnIndex++;
|
|
|
|
}
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!e.AtEnd() && NS_INLINE_IS_BREAK_AFTER(reflowStatus)) {
|
2014-12-29 06:30:00 +03:00
|
|
|
// The current column has been successfully placed.
|
|
|
|
// Skip to the next column and mark break before.
|
2014-11-26 07:52:50 +03:00
|
|
|
e.Next();
|
2014-12-29 07:22:19 +03:00
|
|
|
e.GetColumn(column);
|
2014-11-26 07:52:50 +03:00
|
|
|
reflowStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
}
|
|
|
|
if (!e.AtEnd() || (GetNextInFlow() && !isComplete)) {
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_INLINE_IS_BREAK_BEFORE(reflowStatus)) {
|
2014-12-30 02:05:54 +03:00
|
|
|
if (!columnIndex || !aReflowState.mAllowLineBreak) {
|
2014-12-29 06:30:00 +03:00
|
|
|
// If no column has been placed yet, or we have any span,
|
2014-11-26 07:52:50 +03:00
|
|
|
// the whole container should be in the next line.
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_AFTER(aStatus);
|
2014-12-30 01:24:57 +03:00
|
|
|
MOZ_ASSERT(NS_FRAME_IS_COMPLETE(aStatus) || aReflowState.mAllowLineBreak);
|
2014-11-26 07:52:50 +03:00
|
|
|
|
2014-12-29 07:22:19 +03:00
|
|
|
if (column.mBaseFrame) {
|
|
|
|
PushChildren(column.mBaseFrame, column.mBaseFrame->GetPrevSibling());
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-12-29 07:22:19 +03:00
|
|
|
nsIFrame* textFrame = column.mTextFrames[i];
|
2014-11-26 07:52:50 +03:00
|
|
|
if (textFrame) {
|
2014-12-30 01:56:34 +03:00
|
|
|
aReflowState.mTextContainers[i]->PushChildren(
|
|
|
|
textFrame, textFrame->GetPrevSibling());
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (NS_INLINE_IS_BREAK_AFTER(reflowStatus)) {
|
|
|
|
// |reflowStatus| being break after here may only happen when
|
2014-12-29 06:30:00 +03:00
|
|
|
// there is a break after the column just pulled, or the whole
|
2014-11-26 07:52:50 +03:00
|
|
|
// segment has been completely reflowed. In those cases, we do
|
|
|
|
// not need to push anything.
|
|
|
|
MOZ_ASSERT(e.AtEnd());
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_AFTER(aStatus);
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return icoord - istart;
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
nscoord
|
2014-12-29 07:03:38 +03:00
|
|
|
nsRubyBaseContainerFrame::ReflowOneColumn(const ReflowState& aReflowState,
|
2014-12-30 02:05:54 +03:00
|
|
|
uint32_t aColumnIndex,
|
2014-12-29 07:22:19 +03:00
|
|
|
const RubyColumn& aColumn,
|
2014-12-29 06:30:00 +03:00
|
|
|
nsReflowStatus& aStatus)
|
2014-11-26 07:52:50 +03:00
|
|
|
{
|
2014-12-29 07:03:38 +03:00
|
|
|
const nsHTMLReflowState& baseReflowState = aReflowState.mBaseReflowState;
|
|
|
|
const auto& textReflowStates = aReflowState.mTextReflowStates;
|
|
|
|
|
|
|
|
WritingMode lineWM = baseReflowState.mLineLayout->GetWritingMode();
|
2014-12-30 01:56:34 +03:00
|
|
|
const uint32_t rtcCount = aReflowState.mTextContainers.Length();
|
2014-12-29 07:22:19 +03:00
|
|
|
MOZ_ASSERT(aColumn.mTextFrames.Length() == rtcCount);
|
2014-12-29 07:03:38 +03:00
|
|
|
MOZ_ASSERT(textReflowStates.Length() == rtcCount);
|
|
|
|
nscoord istart = baseReflowState.mLineLayout->GetCurrentICoord();
|
2014-12-29 06:30:00 +03:00
|
|
|
nscoord columnISize = 0;
|
2014-08-15 21:34:20 +04:00
|
|
|
|
2014-12-15 06:37:15 +03:00
|
|
|
nsAutoString baseText;
|
2014-12-29 07:22:19 +03:00
|
|
|
if (aColumn.mBaseFrame) {
|
|
|
|
if (!nsContentUtils::GetNodeTextContent(aColumn.mBaseFrame->GetContent(),
|
2014-12-15 06:37:15 +03:00
|
|
|
true, baseText)) {
|
|
|
|
NS_RUNTIMEABORT("OOM");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
// Reflow text frames
|
2014-11-26 07:52:50 +03:00
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-12-29 07:22:19 +03:00
|
|
|
nsIFrame* textFrame = aColumn.mTextFrames[i];
|
2014-12-15 06:37:15 +03:00
|
|
|
if (textFrame) {
|
|
|
|
MOZ_ASSERT(textFrame->GetType() == nsGkAtoms::rubyTextFrame);
|
|
|
|
nsAutoString annotationText;
|
|
|
|
if (!nsContentUtils::GetNodeTextContent(textFrame->GetContent(),
|
|
|
|
true, annotationText)) {
|
|
|
|
NS_RUNTIMEABORT("OOM");
|
|
|
|
}
|
|
|
|
// Per CSS Ruby spec, the content comparison for auto-hiding
|
|
|
|
// takes place prior to white spaces collapsing (white-space)
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:49 +03:00
|
|
|
nsReflowStatus reflowStatus;
|
2014-12-29 07:03:38 +03:00
|
|
|
nsHTMLReflowMetrics metrics(*textReflowStates[i]);
|
2014-12-13 03:05:02 +03:00
|
|
|
RubyUtils::ClearReservedISize(textFrame);
|
2014-11-26 07:52:48 +03:00
|
|
|
|
|
|
|
bool pushedFrame;
|
2014-12-29 07:03:38 +03:00
|
|
|
textReflowStates[i]->mLineLayout->ReflowFrame(textFrame, reflowStatus,
|
|
|
|
&metrics, pushedFrame);
|
2014-12-22 08:16:06 +03:00
|
|
|
MOZ_ASSERT(!NS_INLINE_IS_BREAK(reflowStatus) && !pushedFrame,
|
|
|
|
"Any line break inside ruby box should has been suppressed");
|
2014-12-29 06:30:00 +03:00
|
|
|
columnISize = std::max(columnISize, metrics.ISize(lineWM));
|
2014-08-15 21:34:20 +04:00
|
|
|
}
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
2014-12-29 07:03:38 +03:00
|
|
|
if (aReflowState.mAllowLineBreak &&
|
|
|
|
ShouldBreakBefore(baseReflowState, columnISize)) {
|
2014-11-26 07:52:50 +03:00
|
|
|
// 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;
|
|
|
|
}
|
2014-08-15 21:34:20 +04:00
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
// Reflow the base frame
|
2014-12-29 07:22:19 +03:00
|
|
|
if (aColumn.mBaseFrame) {
|
|
|
|
MOZ_ASSERT(aColumn.mBaseFrame->GetType() == nsGkAtoms::rubyBaseFrame);
|
2014-11-26 07:52:50 +03:00
|
|
|
nsReflowStatus reflowStatus;
|
2014-12-29 07:03:38 +03:00
|
|
|
nsHTMLReflowMetrics metrics(baseReflowState);
|
2014-12-29 07:22:19 +03:00
|
|
|
RubyUtils::ClearReservedISize(aColumn.mBaseFrame);
|
2014-11-26 07:52:50 +03:00
|
|
|
|
|
|
|
bool pushedFrame;
|
2014-12-29 07:22:19 +03:00
|
|
|
baseReflowState.mLineLayout->ReflowFrame(aColumn.mBaseFrame, reflowStatus,
|
2014-12-29 07:03:38 +03:00
|
|
|
&metrics, pushedFrame);
|
2014-12-22 08:16:06 +03:00
|
|
|
MOZ_ASSERT(!NS_INLINE_IS_BREAK(reflowStatus) && !pushedFrame,
|
|
|
|
"Any line break inside ruby box should has been suppressed");
|
2014-12-29 06:30:00 +03:00
|
|
|
columnISize = std::max(columnISize, metrics.ISize(lineWM));
|
2014-08-15 21:34:20 +04:00
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
// Align all the line layout to the new coordinate.
|
2014-12-29 06:30:00 +03:00
|
|
|
nscoord icoord = istart + columnISize;
|
2014-12-29 07:03:38 +03:00
|
|
|
nscoord deltaISize = icoord - baseReflowState.mLineLayout->GetCurrentICoord();
|
2014-12-13 03:05:02 +03:00
|
|
|
if (deltaISize > 0) {
|
2014-12-29 07:03:38 +03:00
|
|
|
baseReflowState.mLineLayout->AdvanceICoord(deltaISize);
|
2014-12-29 07:22:19 +03:00
|
|
|
if (aColumn.mBaseFrame) {
|
|
|
|
RubyUtils::SetReservedISize(aColumn.mBaseFrame, deltaISize);
|
2014-12-13 03:05:02 +03:00
|
|
|
}
|
|
|
|
}
|
2014-11-26 07:52:50 +03:00
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-12-30 01:56:34 +03:00
|
|
|
if (aReflowState.mTextContainers[i]->IsSpanContainer()) {
|
2014-12-30 01:44:12 +03:00
|
|
|
continue;
|
|
|
|
}
|
2014-12-29 07:03:38 +03:00
|
|
|
nsLineLayout* lineLayout = textReflowStates[i]->mLineLayout;
|
2014-12-29 07:22:19 +03:00
|
|
|
nsIFrame* textFrame = aColumn.mTextFrames[i];
|
2014-12-13 03:05:02 +03:00
|
|
|
nscoord deltaISize = icoord - lineLayout->GetCurrentICoord();
|
|
|
|
if (deltaISize > 0) {
|
|
|
|
lineLayout->AdvanceICoord(deltaISize);
|
|
|
|
if (textFrame) {
|
|
|
|
RubyUtils::SetReservedISize(textFrame, deltaISize);
|
|
|
|
}
|
|
|
|
}
|
2014-12-29 07:22:19 +03:00
|
|
|
if (aColumn.mBaseFrame && textFrame) {
|
2014-12-10 02:04:15 +03:00
|
|
|
lineLayout->AttachLastFrameToBaseLineLayout();
|
|
|
|
}
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
|
2014-12-29 07:03:38 +03:00
|
|
|
if (aReflowState.mAllowLineBreak &&
|
|
|
|
baseReflowState.mLineLayout->NotifyOptionalBreakPosition(
|
2014-12-30 02:05:54 +03:00
|
|
|
this, aColumnIndex + 1, icoord <= baseReflowState.AvailableISize(),
|
2014-12-22 08:52:30 +03:00
|
|
|
gfxBreakPriority::eNormalBreak)) {
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_AFTER(aStatus);
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
|
2014-12-29 06:30:00 +03:00
|
|
|
return columnISize;
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
nsRubyBaseContainerFrame::PullFrameState::PullFrameState(
|
2014-12-30 01:56:34 +03:00
|
|
|
nsRubyBaseContainerFrame* aBaseContainer,
|
|
|
|
const TextContainerArray& aTextContainers)
|
|
|
|
: mBase(aBaseContainer)
|
|
|
|
, mTextContainers(aTextContainers)
|
2014-11-26 07:52:50 +03:00
|
|
|
{
|
2014-12-30 01:56:34 +03:00
|
|
|
const uint32_t rtcCount = aTextContainers.Length();
|
2014-11-26 07:52:50 +03:00
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
2014-12-30 01:56:34 +03:00
|
|
|
mTexts.AppendElement(aTextContainers[i]);
|
2014-11-26 07:52:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-12-29 06:30:00 +03:00
|
|
|
nsRubyBaseContainerFrame::PullOneColumn(nsLineLayout* aLineLayout,
|
|
|
|
PullFrameState& aPullFrameState,
|
2014-12-29 07:22:19 +03:00
|
|
|
RubyColumn& aColumn,
|
2014-12-29 06:30:00 +03:00
|
|
|
bool& aIsComplete)
|
2014-11-26 07:52:50 +03:00
|
|
|
{
|
2014-12-30 01:56:34 +03:00
|
|
|
const TextContainerArray& textContainers = aPullFrameState.mTextContainers;
|
|
|
|
const uint32_t rtcCount = textContainers.Length();
|
2014-11-26 07:52:50 +03:00
|
|
|
|
2014-12-29 07:22:19 +03:00
|
|
|
aColumn.mBaseFrame = PullNextInFlowChild(aPullFrameState.mBase);
|
|
|
|
aIsComplete = !aColumn.mBaseFrame;
|
2014-11-26 07:52:50 +03:00
|
|
|
|
2014-12-29 07:22:19 +03:00
|
|
|
aColumn.mTextFrames.ClearAndRetainStorage();
|
2014-11-26 07:52:50 +03:00
|
|
|
for (uint32_t i = 0; i < rtcCount; i++) {
|
|
|
|
nsIFrame* nextText =
|
2014-12-30 01:56:34 +03:00
|
|
|
textContainers[i]->PullNextInFlowChild(aPullFrameState.mTexts[i]);
|
2014-12-29 07:22:19 +03:00
|
|
|
aColumn.mTextFrames.AppendElement(nextText);
|
2014-11-26 07:52:50 +03:00
|
|
|
// If there exists any frame in continations, we haven't
|
|
|
|
// completed the reflow process.
|
|
|
|
aIsComplete = aIsComplete && !nextText;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aIsComplete) {
|
|
|
|
// We pulled frames from the next line, hence mark it dirty.
|
|
|
|
aLineLayout->SetDirtyNextLine();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
nscoord
|
2014-12-29 07:03:38 +03:00
|
|
|
nsRubyBaseContainerFrame::ReflowSpans(const ReflowState& aReflowState)
|
2014-11-26 07:52:50 +03:00
|
|
|
{
|
2014-12-29 07:03:38 +03:00
|
|
|
WritingMode lineWM =
|
|
|
|
aReflowState.mBaseReflowState.mLineLayout->GetWritingMode();
|
2014-11-26 07:52:49 +03:00
|
|
|
nscoord spanISize = 0;
|
2014-11-26 07:52:50 +03:00
|
|
|
|
2014-12-30 01:56:34 +03:00
|
|
|
for (uint32_t i = 0, iend = aReflowState.mTextContainers.Length();
|
|
|
|
i < iend; i++) {
|
|
|
|
nsRubyTextContainerFrame* container = aReflowState.mTextContainers[i];
|
2014-12-30 01:44:12 +03:00
|
|
|
if (!container->IsSpanContainer()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:49 +03:00
|
|
|
nsIFrame* rtFrame = container->GetFirstPrincipalChild();
|
|
|
|
nsReflowStatus reflowStatus;
|
2014-12-29 07:03:38 +03:00
|
|
|
nsHTMLReflowMetrics metrics(*aReflowState.mTextReflowStates[i]);
|
2014-11-26 07:52:49 +03:00
|
|
|
bool pushedFrame;
|
2014-12-29 07:03:38 +03:00
|
|
|
aReflowState.mTextReflowStates[i]->mLineLayout->
|
|
|
|
ReflowFrame(rtFrame, reflowStatus, &metrics, pushedFrame);
|
2014-12-22 08:16:06 +03:00
|
|
|
MOZ_ASSERT(!NS_INLINE_IS_BREAK(reflowStatus) && !pushedFrame,
|
|
|
|
"Any line break inside ruby box should has been suppressed");
|
2014-11-26 07:52:49 +03:00
|
|
|
spanISize = std::max(spanISize, metrics.ISize(lineWM));
|
|
|
|
}
|
|
|
|
|
2014-11-26 07:52:50 +03:00
|
|
|
return spanISize;
|
2014-08-15 21:34:20 +04:00
|
|
|
}
|