Bug 1055658 part 2 - Add relative positioning support for ruby annotations. r=dbaron

--HG--
extra : source : 3b6cece1b466a724983927329c56dc1d9555b09a
This commit is contained in:
Xidorn Quan 2015-01-12 14:31:55 +11:00
Родитель c7dcc6e79f
Коммит c5346caa22
2 изменённых файлов: 44 добавлений и 0 удалений

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

@ -253,6 +253,21 @@ nsLineLayout::BeginLineReflow(nscoord aICoord, nscoord aBCoord,
pfd->mAscent = 0;
pfd->mSpan = psd;
psd->mFrame = pfd;
nsIFrame* frame = mBlockReflowState->frame;
if (frame->GetType() == nsGkAtoms::rubyTextContainerFrame) {
// Ruby text container won't be reflowed via ReflowFrame, hence the
// relative positioning information should be recorded here.
MOZ_ASSERT(mBaseLineLayout != this);
pfd->mRelativePos =
mBlockReflowState->mStyleDisplay->IsRelativelyPositionedStyle();
if (pfd->mRelativePos) {
MOZ_ASSERT(
mBlockReflowState->GetWritingMode() == frame->GetWritingMode(),
"mBlockReflowState->frame == frame, "
"hence they should have identical writing mode");
pfd->mOffsets = mBlockReflowState->ComputedLogicalOffsets();
}
}
}
void
@ -675,6 +690,7 @@ nsLineLayout::NewPerFrameData(nsIFrame* aFrame)
WritingMode frameWM = aFrame->GetWritingMode();
WritingMode lineWM = mRootSpan->mWritingMode;
pfd->mBounds = LogicalRect(lineWM);
pfd->mOverflowAreas.Clear();
pfd->mMargin = LogicalMargin(lineWM);
pfd->mBorderPadding = LogicalMargin(lineWM);
pfd->mOffsets = LogicalMargin(frameWM);
@ -3040,6 +3056,26 @@ nsLineLayout::ApplyRelativePositioning(PerFrameData* aPFD)
frame->SetPosition(frameWM, origin, mContainerWidth);
}
// This method do relative positioning for ruby annotations.
void
nsLineLayout::RelativePositionAnnotations(PerSpanData* aRubyPSD,
nsOverflowAreas& aOverflowAreas)
{
MOZ_ASSERT(aRubyPSD->mFrame->mFrame->GetType() == nsGkAtoms::rubyFrame);
for (PerFrameData* pfd = aRubyPSD->mFirstFrame; pfd; pfd = pfd->mNext) {
MOZ_ASSERT(pfd->mFrame->GetType() == nsGkAtoms::rubyBaseContainerFrame);
for (PerFrameData* rtc = pfd->mNextAnnotation;
rtc; rtc = rtc->mNextAnnotation) {
nsIFrame* rtcFrame = rtc->mFrame;
MOZ_ASSERT(rtcFrame->GetType() == nsGkAtoms::rubyTextContainerFrame);
ApplyRelativePositioning(rtc);
nsOverflowAreas rtcOverflowAreas;
RelativePositionFrames(rtc->mSpan, rtcOverflowAreas);
aOverflowAreas.UnionWith(rtcOverflowAreas + rtcFrame->GetPosition());
}
}
}
void
nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflowAreas)
{
@ -3134,6 +3170,11 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflo
overflowAreas.UnionWith(r + frame->GetPosition());
}
// Also compute relative position in the annotations.
if (psd->mFrame->mFrame->GetType() == nsGkAtoms::rubyFrame) {
RelativePositionAnnotations(psd, overflowAreas);
}
// If we just computed a spans combined area, we need to update its
// overflow rect...
if (psd != mRootSpan) {

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

@ -667,6 +667,9 @@ protected:
void ApplyRelativePositioning(PerFrameData* aPFD);
void RelativePositionAnnotations(PerSpanData* aRubyPSD,
nsOverflowAreas& aOverflowAreas);
void RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflowAreas);
bool TrimTrailingWhiteSpaceIn(PerSpanData* psd, nscoord* aDeltaISize);