Bug 1098275 - Inlinize block-level boxes inside ruby. r=heycam

--HG--
extra : rebase_source : 70a969d3a6be4ea5dfe14777aa7c31189ade7211
extra : source : 30e0ea21cdfaa29f2c138f0b8975da984e8ac009
This commit is contained in:
Xidorn Quan 2014-12-11 09:26:18 +11:00
parent 492feded89
commit 2f01e225e3
4 changed files with 27 additions and 8 deletions

View File

@ -2904,6 +2904,13 @@ ElementRestyler::ComputeRestyleResultFromNewContext(nsIFrame* aSelf,
return eRestyleResult_Continue;
}
if (oldContext->IsDirectlyInsideRuby() !=
aNewContext->IsDirectlyInsideRuby()) {
LOG_RESTYLE_CONTINUE("NS_STYLE_IS_DIRECTLY_INSIDE_RUBY differes between old"
" and new style contexts");
return eRestyleResult_Continue;
}
return eRestyleResult_Stop;
}

View File

@ -507,8 +507,8 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
// # The computed 'display' of a flex item is determined
// # by applying the table in CSS 2.1 Chapter 9.7.
// ...which converts inline-level elements to their block-level equivalents.
// Any direct children of elements with Ruby display values which are
// block-level are converted to their inline-level equivalents.
// Any block-level element directly contained by elements with ruby display
// values are converted to their inline-level equivalents.
if (!aSkipParentDisplayBasedStyleFixup && mParent) {
// Skip display:contents ancestors to reach the potential container.
// (If there are only display:contents ancestors between this node and
@ -558,12 +558,17 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
mutable_display->mDisplay = displayVal;
}
}
} else if (containerDisp->IsRubyDisplayType()) {
}
// The display change should only occur for "in-flow" children
if (!disp->IsOutOfFlowStyle() &&
((containerDisp->mDisplay == NS_STYLE_DISPLAY_INLINE &&
containerContext->IsDirectlyInsideRuby()) ||
containerDisp->IsRubyDisplayType())) {
mBits |= NS_STYLE_IS_DIRECTLY_INSIDE_RUBY;
uint8_t displayVal = disp->mDisplay;
nsRuleNode::EnsureInlineDisplay(displayVal);
// The display change should only occur for "in-flow" children
if (displayVal != disp->mDisplay &&
!disp->IsOutOfFlowStyle()) {
if (displayVal != disp->mDisplay) {
nsStyleDisplay *mutable_display =
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
mutable_display->mDisplay = displayVal;

View File

@ -130,6 +130,12 @@ 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 IsDirectlyInsideRuby() const
{ return !!(mBits & NS_STYLE_IS_DIRECTLY_INSIDE_RUBY); }
// Does this style context represent the style for a pseudo-element or
// inherit data from such a style context? Whether this returns true
// is equivalent to whether it or any of its ancestors returns

View File

@ -56,9 +56,10 @@ class imgIContainer;
// See nsStyleContext::AssertStructsNotUsedElsewhere
// (This bit is currently only used in #ifdef DEBUG code.)
#define NS_STYLE_IS_GOING_AWAY 0x040000000
// See nsStyleContext::IsDirectlyInsideRuby
#define NS_STYLE_IS_DIRECTLY_INSIDE_RUBY 0x080000000
// See nsStyleContext::GetPseudoEnum
#define NS_STYLE_CONTEXT_TYPE_MASK 0xf80000000
#define NS_STYLE_CONTEXT_TYPE_SHIFT 31
#define NS_STYLE_CONTEXT_TYPE_SHIFT 32
// Additional bits for nsRuleNode's mDependentBits:
#define NS_RULE_NODE_GC_MARK 0x02000000