Bug 1157011 - Check line break suppression of BR frame from its parent frame. r=dholbert

This commit is contained in:
Xidorn Quan 2015-04-23 13:32:53 +12:00
parent 764fdec98b
commit 8c492e64b7
4 changed files with 28 additions and 4 deletions

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<html>
<body style="display: inline-flex;"><div><div style="display: ruby-base;">f<br style="display: ruby-base-container;"></div></div></body>
</html>

View File

@ -583,3 +583,4 @@ load 1146103.html
load 1146107.html
load 1146114.html
load 1156222.html
load 1157011.html

View File

@ -96,9 +96,13 @@ BRFrame::Reflow(nsPresContext* aPresContext,
aMetrics.SetBlockStartAscent(0);
// 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.
// behave like a BR. Additionally, we suppress breaks from BR inside
// of ruby frames. To determine if we're inside ruby, we have to rely
// on the *parent's* ShouldSuppressLineBreak() method, instead of our
// own, because we may have custom "display" value that makes our
// ShouldSuppressLineBreak() return false.
nsLineLayout* ll = aReflowState.mLineLayout;
if (ll && !StyleContext()->ShouldSuppressLineBreak()) {
if (ll && !GetParent()->StyleContext()->ShouldSuppressLineBreak()) {
// Note that the compatibility mode check excludes AlmostStandards
// mode, since this is the inline box model. See bug 161691.
if ( ll->LineIsEmpty() ||
@ -165,7 +169,7 @@ BRFrame::Reflow(nsPresContext* aPresContext,
BRFrame::AddInlineMinISize(nsRenderingContext *aRenderingContext,
nsIFrame::InlineMinISizeData *aData)
{
if (!StyleContext()->ShouldSuppressLineBreak()) {
if (!GetParent()->StyleContext()->ShouldSuppressLineBreak()) {
aData->ForceBreak(aRenderingContext);
}
}
@ -174,7 +178,7 @@ BRFrame::AddInlineMinISize(nsRenderingContext *aRenderingContext,
BRFrame::AddInlinePrefISize(nsRenderingContext *aRenderingContext,
nsIFrame::InlinePrefISizeData *aData)
{
if (!StyleContext()->ShouldSuppressLineBreak()) {
if (!GetParent()->StyleContext()->ShouldSuppressLineBreak()) {
aData->ForceBreak(aRenderingContext);
}
}

View File

@ -548,6 +548,21 @@ ShouldSuppressLineBreak(const nsStyleDisplay* aStyleDisplay,
// 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.
// Note that, when certain HTML tags, e.g. form controls, have ruby
// level container display type, they could also escape from this flag
// while they shouldn't. However, it is generally fine since they
// won't usually break the assertion that there is no line break
// inside ruby, because:
// 1. their display types, the ruby level container types, are inline-
// outside, which means they won't cause any forced line break; and
// 2. they never start an inline span, which means their children, if
// any, won't be able to break the line its ruby ancestor lays; and
// 3. their parent frame is always a ruby content frame (due to
// anonymous ruby box generation), which makes line layout suppress
// any optional line break around this frame.
// 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() &&
aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER &&
aStyleDisplay->mDisplay != NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER) ||