Bug 1230408 - Move suppress line break check out from control of SkipParentDisplayBasedStyleFixup. r=dbaron

The flag SkipParentDisplayBasedStyleFixup is for flex/grid fixup, and it is set
for all pseudo elements other than before/after. This is not desirable for ruby
case.

Moving the code out also means elements will inherit the suppress flag directly
from "display: contents" parent (instead of the container), which is fine since
the parent should have had its flag set properly as well.

--HG--
extra : source : ab8d1c650ec6aa41cb165c278de9e06182a0c733
This commit is contained in:
Xidorn Quan 2016-01-08 14:34:08 +11:00
Родитель bf16ee017a
Коммит 68c176f928
3 изменённых файлов: 32 добавлений и 21 удалений

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

@ -0,0 +1,8 @@
<!DOCTYPE html>
<style>
body { width: 1px; }
body:first-letter { }
</style>
<body>
<rb>C</rb>
</body>

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

@ -132,6 +132,7 @@ load 1223688-1.html
load 1223694-1.html
load 1226400-1.html
load 1227501-1.html
load 1230408-1.html
load border-image-visited-link.html
load font-face-truncated-src.html
load large_border_image_width.html

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

@ -512,19 +512,21 @@ nsStyleContext::SetStyle(nsStyleStructID aSID, void* aStruct)
static bool
ShouldSuppressLineBreak(const nsStyleDisplay* aStyleDisplay,
const nsStyleContext* aContainerContext,
const nsStyleDisplay* aContainerDisplay)
const nsStyleContext* aParentContext,
const nsStyleDisplay* aParentDisplay)
{
// 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) {
if (aParentContext->ShouldSuppressLineBreak()) {
// Line break suppressing bit is propagated to any children of
// line participants, which include inline, contents, and inline
// ruby boxes.
if (aParentDisplay->mDisplay == NS_STYLE_DISPLAY_INLINE ||
aParentDisplay->mDisplay == NS_STYLE_DISPLAY_CONTENTS ||
aParentDisplay->mDisplay == NS_STYLE_DISPLAY_RUBY ||
aParentDisplay->mDisplay == NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER) {
return true;
}
}
@ -547,7 +549,7 @@ ShouldSuppressLineBreak(const nsStyleDisplay* aStyleDisplay,
// However, there is one special case which is BR tag, because it
// directly affects the line layout. This case is handled by the BR
// frame which checks the flag of its parent frame instead of itself.
if ((aContainerDisplay->IsRubyDisplayType() &&
if ((aParentDisplay->IsRubyDisplayType() &&
aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER &&
aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER) ||
// Since ruby base and ruby text may exist themselves without any
@ -704,18 +706,6 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
}
}
}
if (::ShouldSuppressLineBreak(disp, containerContext, containerDisp)) {
mBits |= NS_STYLE_SUPPRESS_LINEBREAK;
uint8_t displayVal = disp->mDisplay;
nsRuleNode::EnsureInlineDisplay(displayVal);
if (displayVal != disp->mDisplay) {
nsStyleDisplay* mutable_display =
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
disp = mutable_display;
mutable_display->mDisplay = displayVal;
}
}
}
// Set the NS_STYLE_IN_DISPLAY_NONE_SUBTREE bit
@ -724,6 +714,18 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
mBits |= NS_STYLE_IN_DISPLAY_NONE_SUBTREE;
}
if (mParent && ::ShouldSuppressLineBreak(disp, mParent,
mParent->StyleDisplay())) {
mBits |= NS_STYLE_SUPPRESS_LINEBREAK;
uint8_t displayVal = disp->mDisplay;
nsRuleNode::EnsureInlineDisplay(displayVal);
if (displayVal != disp->mDisplay) {
nsStyleDisplay* mutable_display =
static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
disp = mutable_display;
mutable_display->mDisplay = displayVal;
}
}
// Suppress border/padding of ruby level containers
if (disp->mDisplay == NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER ||
disp->mDisplay == NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER) {