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
Родитель 60c2db8aac
Коммит 4acbb5abac
4 изменённых файлов: 27 добавлений и 8 удалений

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

@ -2904,6 +2904,13 @@ ElementRestyler::ComputeRestyleResultFromNewContext(nsIFrame* aSelf,
return eRestyleResult_Continue; 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; return eRestyleResult_Stop;
} }

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

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

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

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

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

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