Bug 1117597 - Sync bounds of ruby annotation containers. r=roc

--HG--
extra : rebase_source : 336b023e6d44031a3a2adfde42a510b6729d83a3
extra : source : a2e4eb7e9c71f299685e8e4c9175bfb31a27a70b
This commit is contained in:
Xidorn Quan 2015-01-07 12:47:09 +11:00
parent 676a72ac80
commit 172cb2654c
5 changed files with 54 additions and 5 deletions

View File

@ -996,6 +996,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
} else {
if (nsGkAtoms::letterFrame==frameType) {
pfd->mIsLetterFrame = true;
} else if (nsGkAtoms::rubyFrame == frameType) {
SyncAnnotationContainersBounds(pfd);
}
if (pfd->mSpan) {
isEmpty = !pfd->mSpan->mHasNonemptyContent && pfd->mFrame->IsSelfEmpty();
@ -1205,6 +1207,30 @@ nsLineLayout::GetCurrentFrameInlineDistanceFromBlock()
return x;
}
/**
* This method syncs all ruby annotation containers' bounds in their
* PerFrameData from their rect. It is necessary to do so because the
* containers are not part of line in their levels, which means their
* bounds are not set properly before.
*/
void
nsLineLayout::SyncAnnotationContainersBounds(PerFrameData* aRubyFrame)
{
MOZ_ASSERT(aRubyFrame->mFrame->GetType() == nsGkAtoms::rubyFrame);
MOZ_ASSERT(aRubyFrame->mSpan);
PerSpanData* span = aRubyFrame->mSpan;
WritingMode lineWM = mRootSpan->mWritingMode;
nscoord containerWidth = ContainerWidthForSpan(span);
for (PerFrameData* pfd = span->mFirstFrame; pfd; pfd = pfd->mNext) {
for (PerFrameData* annotation = pfd->mNextAnnotation;
annotation; annotation = annotation->mNextAnnotation) {
LogicalRect bounds(lineWM, annotation->mFrame->GetRect(), containerWidth);
annotation->mBounds = bounds;
}
}
}
/**
* See if the frame can be placed now that we know it's desired size.
* We can always place the frame if the line is empty. Note that we
@ -2639,8 +2665,7 @@ nsLineLayout::AdvanceAnnotationInlineBounds(PerFrameData* aPFD,
PerSpanData* psd = aPFD->mSpan;
WritingMode lineWM = mRootSpan->mWritingMode;
LogicalRect bounds(lineWM, frame->GetRect(), aContainerWidth);
bounds.IStart(lineWM) += aDeltaICoord;
aPFD->mBounds.IStart(lineWM) += aDeltaICoord;
// Check whether this expansion should be counted into the reserved
// isize or not. When it is a ruby text container, and it has some
@ -2659,10 +2684,9 @@ nsLineLayout::AdvanceAnnotationInlineBounds(PerFrameData* aPFD,
} else {
// It is a normal ruby text container. Its children will expand
// themselves properly. We only need to expand its own size here.
bounds.ISize(lineWM) += aDeltaISize;
aPFD->mBounds.ISize(lineWM) += aDeltaISize;
}
aPFD->mBounds = bounds;
aPFD->mFrame->SetRect(lineWM, bounds, aContainerWidth);
aPFD->mFrame->SetRect(lineWM, aPFD->mBounds, aContainerWidth);
}
/**

View File

@ -646,6 +646,8 @@ protected:
void AllowForStartMargin(PerFrameData* pfd,
nsHTMLReflowState& aReflowState);
void SyncAnnotationContainersBounds(PerFrameData* aRubyFrame);
bool CanPlaceFrame(PerFrameData* pfd,
bool aNotSafeToBreak,
bool aFrameCanContinueTextRun,

View File

@ -22,6 +22,7 @@ fuzzy-if(winWidget,28,1) == dynamic-removal-3.html dynamic-removal-3-ref.html #
== inlinize-blocks-5.html inlinize-blocks-5-ref.html
== justification-1.html justification-1-ref.html
== justification-2.html justification-2-ref.html
== ruby-span-1.html ruby-span-1-ref.html
== ruby-whitespace-1.html ruby-whitespace-1-ref.html
== ruby-whitespace-2.html ruby-whitespace-2-ref.html
== ruby-position-horizontal.html ruby-position-horizontal-ref.html

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug 1117597</title>
<link rel="stylesheet" href="common.css">
</head>
<body>
<ruby><rb>The Ruby Base</rb><rtc><rt>span</rt></rtc></ruby>
</body>
</html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug 1117597</title>
<link rel="stylesheet" href="common.css">
</head>
<body>
<ruby><rb>The Ruby Base</rb><rtc>span</rtc></ruby>
</body>
</html>