Bug 1055665 part 3 - Position ruby annotations and set the line size of them correctly. r=dholbert

--HG--
extra : source : c4dff2a39c852a249a5ff6e929780d898ba956ac
This commit is contained in:
Xidorn Quan 2014-12-09 17:47:26 +11:00
Родитель 4156dfaf68
Коммит 83ed4953c7
7 изменённых файлов: 35 добавлений и 21 удалений

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

@ -98,6 +98,9 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
mTotalPlacedFrames = 0;
mBStartEdge = 0;
mTrimmableISize = 0;
#ifdef DEBUG
mFinalLineBSize = nscoord_MIN;
#endif
mInflationMinFontSize =
nsLayoutUtils::InflationMinFontSizeFor(aOuterReflowState->frame);

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

@ -116,6 +116,15 @@ public:
*/
void VerticalAlignLine();
// Get the final size of the line, in the block direction.
// Do not call this until after we've called VerticalAlignLine.
nscoord GetFinalLineBSize() const
{
NS_ASSERTION(mFinalLineBSize != nscoord_MIN,
"VerticalAlignLine should have been called before");
return mFinalLineBSize;
}
bool TrimTrailingWhiteSpace();
/**

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

@ -409,10 +409,10 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext,
// when it is reflowed, it will just use this size.
nsRubyTextContainerFrame* textContainer = i < rtcCount ?
mTextContainers[i] : mSpanContainers[i - rtcCount];
RubyUtils::ClearReservedISize(textContainer);
textContainer->SetISize(isize);
nsLineLayout* lineLayout = lineLayouts[i].get();
nscoord rtcISize = lineLayouts[i]->GetCurrentICoord();
RubyUtils::ClearReservedISize(textContainer);
nscoord rtcISize = lineLayout->GetCurrentICoord();
// Only span containers and containers with collapsed annotations
// need reserving isize. For normal ruby text containers, their
// children will be expanded properly. We only need to expand their
@ -422,7 +422,11 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext,
} else if (isize > rtcISize) {
RubyUtils::SetReservedISize(textContainer, isize - rtcISize);
}
lineLayouts[i]->EndLineReflow();
lineLayout->VerticalAlignLine();
LogicalSize lineSize(lineWM, isize, lineLayout->GetFinalLineBSize());
textContainer->SetLineSize(lineSize);
lineLayout->EndLineReflow();
}
aDesiredSize.ISize(lineWM) = isize;

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

@ -71,7 +71,8 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext,
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
// All rt children have already been reflowed. All we need to do is
// to report complete and return the desired size.
// to report complete and return the desired size provided by the
// ruby base container.
// Although a ruby text container may have continuations, returning
// NS_FRAME_COMPLETE here is still safe, since its parent, ruby frame,
@ -79,12 +80,5 @@ nsRubyTextContainerFrame::Reflow(nsPresContext* aPresContext,
// will take care of our continuations.
aStatus = NS_FRAME_COMPLETE;
WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
WritingMode frameWM = aReflowState.GetWritingMode();
LogicalMargin borderPadding = aReflowState.ComputedLogicalBorderPadding();
// ISize is provided by the ruby base container
// during reflow of that container.
aDesiredSize.ISize(lineWM) = mISize;
nsLayoutUtils::SetBSizeFromFontMetrics(this, aDesiredSize, aReflowState,
borderPadding, lineWM, frameWM);
aDesiredSize.SetSize(lineWM, mLineSize);
}

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

@ -47,15 +47,16 @@ protected:
NS_NewRubyTextContainerFrame(nsIPresShell* aPresShell,
nsStyleContext* aContext);
explicit nsRubyTextContainerFrame(nsStyleContext* aContext)
: nsRubyTextContainerFrameSuper(aContext) {}
: nsRubyTextContainerFrameSuper(aContext)
, mLineSize(mozilla::WritingMode(aContext)) {}
friend class nsRubyBaseContainerFrame;
void SetISize(nscoord aISize) { mISize = aISize; }
void SetLineSize(const mozilla::LogicalSize& aSize) { mLineSize = aSize; }
// The intended dimensions of the ruby text container. These are modified
// whenever a ruby text box is reflowed and used when the ruby text container
// is reflowed.
nscoord mISize;
// The intended dimensions of the ruby text container. It is set by
// the corresponding ruby base container when the segment is reflowed,
// and used when the ruby text container is reflowed by its parent.
mozilla::LogicalSize mLineSize;
};
#endif /* nsRubyTextContainerFrame_h___ */

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

@ -90,7 +90,10 @@ nsRubyTextFrame::Reflow(nsPresContext* aPresContext,
aReflowState, aStatus);
if (GetStateBits() & NS_RUBY_TEXT_FRAME_AUTOHIDE) {
aDesiredSize.ClearSize();
// Reset the ISize. The BSize is not changed so that it won't
// affect vertical positioning in unexpected way.
WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
aDesiredSize.ISize(lineWM) = 0;
aDesiredSize.SetOverflowAreasToDesiredBounds();
}
}

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

@ -2,7 +2,7 @@ default-preferences pref(layout.css.ruby.enabled,true)
== autohiding-1.html autohiding-1-ref.html
== autohiding-2.html autohiding-2-ref.html
== autohiding-3.html autohiding-3-ref.html
fails == autohiding-3.html autohiding-3-ref.html # bug 1107701
== box-generation-1.html box-generation-1-ref.html
== box-generation-2.html box-generation-2-ref.html
== box-generation-3.html box-generation-3-ref.html