Bug 1140264 part 3 - Rename IsInlineDescendantOfRuby to ShouldSuppressLineBreak and exclude rbc/rtc from it. r=dbaron

--HG--
extra : rebase_source : b782506792fd47e41c694a49fca3967282c96113
extra : source : 9836c81fe7d401432856491dc65c38b150e5e157
This commit is contained in:
Xidorn Quan 2015-03-11 10:28:21 +11:00
Родитель b5e5ccaa5b
Коммит e89adacefb
9 изменённых файлов: 60 добавлений и 32 удалений

Просмотреть файл

@ -3023,9 +3023,9 @@ ElementRestyler::ComputeRestyleResultFromNewContext(nsIFrame* aSelf,
return eRestyleResult_Continue;
}
if (oldContext->IsInlineDescendantOfRuby() !=
aNewContext->IsInlineDescendantOfRuby()) {
LOG_RESTYLE_CONTINUE("NS_STYLE_IS_INLINE_DESCENDANT_OF_RUBY differes"
if (oldContext->ShouldSuppressLineBreak() !=
aNewContext->ShouldSuppressLineBreak()) {
LOG_RESTYLE_CONTINUE("NS_STYLE_SUPPRESS_LINEBREAK differes"
"between old and new style contexts");
return eRestyleResult_Continue;
}

Просмотреть файл

@ -97,7 +97,7 @@ BRFrame::Reflow(nsPresContext* aPresContext,
// Only when the BR is operating in a line-layout situation will it
// behave like a BR. BR is suppressed when it is inside ruby frames.
nsLineLayout* ll = aReflowState.mLineLayout;
if (ll && !StyleContext()->IsInlineDescendantOfRuby()) {
if (ll && !StyleContext()->ShouldSuppressLineBreak()) {
// Note that the compatibility mode check excludes AlmostStandards
// mode, since this is the inline box model. See bug 161691.
if ( ll->LineIsEmpty() ||
@ -164,7 +164,7 @@ BRFrame::Reflow(nsPresContext* aPresContext,
BRFrame::AddInlineMinISize(nsRenderingContext *aRenderingContext,
nsIFrame::InlineMinISizeData *aData)
{
if (!StyleContext()->IsInlineDescendantOfRuby()) {
if (!StyleContext()->ShouldSuppressLineBreak()) {
aData->ForceBreak(aRenderingContext);
}
}
@ -173,7 +173,7 @@ BRFrame::AddInlineMinISize(nsRenderingContext *aRenderingContext,
BRFrame::AddInlinePrefISize(nsRenderingContext *aRenderingContext,
nsIFrame::InlinePrefISizeData *aData)
{
if (!StyleContext()->IsInlineDescendantOfRuby()) {
if (!StyleContext()->ShouldSuppressLineBreak()) {
aData->ForceBreak(aRenderingContext);
}
}

Просмотреть файл

@ -3929,7 +3929,7 @@ nsFrame::AddInlineMinISize(nsRenderingContext *aRenderingContext,
NS_ASSERTION(GetParent(), "Must have a parent if we get here!");
nsIFrame* parent = GetParent();
bool canBreak = !CanContinueTextRun() &&
!parent->StyleContext()->IsInlineDescendantOfRuby() &&
!parent->StyleContext()->ShouldSuppressLineBreak() &&
parent->StyleText()->WhiteSpaceCanWrap(parent);
if (canBreak)

Просмотреть файл

@ -457,7 +457,7 @@ nsLineLayout::BeginSpan(nsIFrame* aFrame,
nsIFrame* frame = aSpanReflowState->frame;
psd->mNoWrap = !frame->StyleText()->WhiteSpaceCanWrap(frame) ||
mSuppressLineWrap ||
frame->StyleContext()->IsInlineDescendantOfRuby();
frame->StyleContext()->ShouldSuppressLineBreak();
psd->mWritingMode = aSpanReflowState->GetWritingMode();
// Switch to new span
@ -2896,7 +2896,7 @@ nsLineLayout::ApplyFrameJustification(PerSpanData* aPSD,
static nsIFrame*
FindNearestRubyBaseAncestor(nsIFrame* aFrame)
{
MOZ_ASSERT(aFrame->StyleContext()->IsInlineDescendantOfRuby());
MOZ_ASSERT(aFrame->StyleContext()->ShouldSuppressLineBreak());
while (aFrame && aFrame->GetType() != nsGkAtoms::rubyBaseFrame) {
aFrame = aFrame->GetParent();
}
@ -3071,7 +3071,7 @@ nsLineLayout::TextAlignLine(nsLineBox* aLine,
ComputeFrameJustification(psd, computeState);
if (mHasRuby && computeState.mFirstParticipant) {
PerFrameData* firstFrame = computeState.mFirstParticipant;
if (firstFrame->mFrame->StyleContext()->IsInlineDescendantOfRuby()) {
if (firstFrame->mFrame->StyleContext()->ShouldSuppressLineBreak()) {
MOZ_ASSERT(!firstFrame->mJustificationAssignment.mGapsAtStart);
nsIFrame* rubyBase = FindNearestRubyBaseAncestor(firstFrame->mFrame);
if (rubyBase && IsRubyAlignSpaceAround(rubyBase)) {
@ -3080,7 +3080,7 @@ nsLineLayout::TextAlignLine(nsLineBox* aLine,
}
}
PerFrameData* lastFrame = computeState.mLastParticipant;
if (lastFrame->mFrame->StyleContext()->IsInlineDescendantOfRuby()) {
if (lastFrame->mFrame->StyleContext()->ShouldSuppressLineBreak()) {
MOZ_ASSERT(!lastFrame->mJustificationAssignment.mGapsAtEnd);
nsIFrame* rubyBase = FindNearestRubyBaseAncestor(lastFrame->mFrame);
if (rubyBase && IsRubyAlignSpaceAround(rubyBase)) {

Просмотреть файл

@ -250,14 +250,14 @@ GetIsLineBreakAllowed(nsIFrame* aFrame, bool aIsLineBreakable,
bool* aAllowInitialLineBreak, bool* aAllowLineBreak)
{
nsIFrame* parent = aFrame->GetParent();
bool inNestedRuby = parent->StyleContext()->IsInlineDescendantOfRuby();
bool lineBreakSuppressed = parent->StyleContext()->ShouldSuppressLineBreak();
// 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 &&
bool allowLineBreak = !lineBreakSuppressed &&
aFrame->StyleText()->WhiteSpaceCanWrap(aFrame);
bool allowInitialLineBreak = allowLineBreak;
if (!aFrame->GetPrevInFlow()) {
allowInitialLineBreak = !inNestedRuby &&
allowInitialLineBreak = !lineBreakSuppressed &&
parent->StyleText()->WhiteSpaceCanWrap(parent);
}
if (!aIsLineBreakable) {

Просмотреть файл

@ -1927,7 +1927,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
textFlags |= GetSpacingFlags(WordSpacing(f));
nsTextFrameUtils::CompressionMode compression =
CSSWhitespaceToCompressionMode[textStyle->mWhiteSpace];
if ((enabledJustification || f->StyleContext()->IsInlineDescendantOfRuby()) &&
if ((enabledJustification || f->StyleContext()->ShouldSuppressLineBreak()) &&
!textStyle->WhiteSpaceIsSignificant() && !isSVG) {
textFlags |= gfxTextRunFactory::TEXT_ENABLE_SPACING;
}
@ -2803,7 +2803,7 @@ static int32_t FindChar(const nsTextFragment* frag,
static bool IsChineseOrJapanese(nsIFrame* aFrame)
{
if (aFrame->StyleContext()->IsInlineDescendantOfRuby()) {
if (aFrame->StyleContext()->ShouldSuppressLineBreak()) {
// Always treat ruby as CJ language so that those characters can
// be expanded properly even when surrounded by other language.
return true;
@ -8295,7 +8295,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
gfxBreakPriority breakPriority;
aLineLayout.GetLastOptionalBreakPosition(&unusedOffset, &breakPriority);
gfxTextRun::SuppressBreak suppressBreak = gfxTextRun::eNoSuppressBreak;
if (StyleContext()->IsInlineDescendantOfRuby()) {
if (StyleContext()->ShouldSuppressLineBreak()) {
suppressBreak = gfxTextRun::eSuppressAllBreaks;
} else if (!aLineLayout.LineIsBreakable()) {
suppressBreak = gfxTextRun::eSuppressInitialBreak;
@ -8506,7 +8506,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
bool emptyTextAtStartOfLine = atStartOfLine && length == 0;
if (!breakAfter && charsFit == length && !emptyTextAtStartOfLine &&
transformedOffset + transformedLength == mTextRun->GetLength() &&
!StyleContext()->IsInlineDescendantOfRuby() &&
!StyleContext()->ShouldSuppressLineBreak() &&
(mTextRun->GetFlags() & nsTextFrameUtils::TEXT_HAS_TRAILING_BREAK)) {
// We placed all the text in the textrun and we have a break opportunity at
// the end of the textrun. We need to record it because the following
@ -8568,7 +8568,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
if (!textStyle->WhiteSpaceIsSignificant() &&
(lineContainer->StyleText()->mTextAlign == NS_STYLE_TEXT_ALIGN_JUSTIFY ||
lineContainer->StyleText()->mTextAlignLast == NS_STYLE_TEXT_ALIGN_JUSTIFY ||
StyleContext()->IsInlineDescendantOfRuby()) &&
StyleContext()->ShouldSuppressLineBreak()) &&
!lineContainer->IsSVGText()) {
AddStateBits(TEXT_JUSTIFICATION_ENABLED);
provider.ComputeJustification(offset, charsFit);

Просмотреть файл

@ -516,6 +516,36 @@ nsStyleContext::SetStyle(nsStyleStructID aSID, void* aStruct)
*dataSlot = aStruct;
}
static bool
ShouldSuppressLineBreak(const nsStyleDisplay* aStyleDisplay,
const nsStyleContext* aContainerContext,
const nsStyleDisplay* aContainerDisplay)
{
// The display change should only occur for "in-flow" children
if (aStyleDisplay->IsOutOfFlowStyle()) {
return false;
}
if (aContainerContext->ShouldSuppressLineBreak()) {
// Line break suppressing bit is propagated to any children of line
// participants, which include inline and inline ruby boxes.
if (aContainerDisplay->mDisplay == NS_STYLE_DISPLAY_INLINE ||
aContainerDisplay->mDisplay == NS_STYLE_DISPLAY_RUBY ||
aContainerDisplay->mDisplay == NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER) {
return true;
}
}
// Any descendant of ruby level containers is non-breakable, but
// the level containers themselves are breakable. We have to check
// the container display type against all ruby display type here
// because any of the ruby boxes could be anonymous.
if (aContainerDisplay->IsRubyDisplayType() &&
aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER &&
aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER) {
return true;
}
return false;
}
void
nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
{
@ -642,12 +672,8 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
}
}
// The display change should only occur for "in-flow" children
if (!disp->IsOutOfFlowStyle() &&
((containerDisp->mDisplay == NS_STYLE_DISPLAY_INLINE &&
containerContext->IsInlineDescendantOfRuby()) ||
containerDisp->IsRubyDisplayType())) {
mBits |= NS_STYLE_IS_INLINE_DESCENDANT_OF_RUBY;
if (::ShouldSuppressLineBreak(disp, containerContext, containerDisp)) {
mBits |= NS_STYLE_SUPPRESS_LINEBREAK;
uint8_t displayVal = disp->mDisplay;
nsRuleNode::EnsureInlineDisplay(displayVal);
if (displayVal != disp->mDisplay) {

Просмотреть файл

@ -152,11 +152,13 @@ public:
bool HasTextDecorationLines() const
{ return !!(mBits & NS_STYLE_HAS_TEXT_DECORATION_LINES); }
// Whether this style context or any of its inline-level ancestors
// is directly contained by a ruby box? It is used to inlinize
// block-level descendants and suppress line breaks inside ruby.
bool IsInlineDescendantOfRuby() const
{ return !!(mBits & NS_STYLE_IS_INLINE_DESCENDANT_OF_RUBY); }
// Whether any line break inside should be suppressed? If this returns
// true, the line should not be broken inside, which means inlines act
// as if nowrap is set, <br> is suppressed, and blocks are inlinized.
// This bit is propogated to all children of line partitipants. It is
// currenlty used by ruby to make its content frames unbreakable.
bool ShouldSuppressLineBreak() const
{ return !!(mBits & NS_STYLE_SUPPRESS_LINEBREAK); }
// Does this style context represent the style for a pseudo-element or
// inherit data from such a style context? Whether this returns true

Просмотреть файл

@ -56,8 +56,8 @@ class imgIContainer;
// See nsStyleContext::AssertStructsNotUsedElsewhere
// (This bit is currently only used in #ifdef DEBUG code.)
#define NS_STYLE_IS_GOING_AWAY 0x040000000
// See nsStyleContext::IsInlineDescendantOfRuby
#define NS_STYLE_IS_INLINE_DESCENDANT_OF_RUBY 0x080000000
// See nsStyleContext::ShouldSuppressLineBreak
#define NS_STYLE_SUPPRESS_LINEBREAK 0x080000000
// See nsStyleContext::GetPseudoEnum
#define NS_STYLE_CONTEXT_TYPE_SHIFT 32