зеркало из https://github.com/mozilla/gecko-dev.git
Bug 401178 - incorrect ascents for foreign children in nsMathMLContainerFrame::ReflowChild. r+sr=roc
This commit is contained in:
Родитель
724b719ea9
Коммит
b6a6ab3499
|
@ -982,16 +982,6 @@ nsMathMLContainerFrame::ReflowChild(nsIFrame* aChildFrame,
|
||||||
const nsHTMLReflowState& aReflowState,
|
const nsHTMLReflowState& aReflowState,
|
||||||
nsReflowStatus& aStatus)
|
nsReflowStatus& aStatus)
|
||||||
{
|
{
|
||||||
aDesiredSize.width = aDesiredSize.height = 0;
|
|
||||||
aDesiredSize.ascent = 0;
|
|
||||||
aDesiredSize.mBoundingMetrics.Clear();
|
|
||||||
PRBool isForeign = IsForeignChild(aChildFrame);
|
|
||||||
if (!isForeign) {
|
|
||||||
// We only do this for MathML frames now. Non-MathML frames support
|
|
||||||
// ComputeTightBounds instead.
|
|
||||||
aDesiredSize.mFlags |= NS_REFLOW_CALC_BOUNDING_METRICS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Having foreign/hybrid children, e.g., from html markups, is not defined by
|
// Having foreign/hybrid children, e.g., from html markups, is not defined by
|
||||||
// the MathML spec. But it can happen in practice, e.g., <html:img> allows us
|
// the MathML spec. But it can happen in practice, e.g., <html:img> allows us
|
||||||
// to do some cool demos... or we may have a child that is an nsInlineFrame
|
// to do some cool demos... or we may have a child that is an nsInlineFrame
|
||||||
|
@ -1014,17 +1004,27 @@ nsMathMLContainerFrame::ReflowChild(nsIFrame* aChildFrame,
|
||||||
nsresult rv = nsHTMLContainerFrame::
|
nsresult rv = nsHTMLContainerFrame::
|
||||||
ReflowChild(aChildFrame, aPresContext, aDesiredSize, aReflowState,
|
ReflowChild(aChildFrame, aPresContext, aDesiredSize, aReflowState,
|
||||||
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
||||||
if (isForeign) {
|
|
||||||
// use ComputeTightBounds API instead
|
if (aDesiredSize.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE) {
|
||||||
|
// This will be suitable for inline frames, which are wrapped in a block.
|
||||||
|
if(!nsLayoutUtils::GetLastLineBaseline(aChildFrame,
|
||||||
|
&aDesiredSize.ascent)) {
|
||||||
|
// We don't expect any other block children so just place the frame on
|
||||||
|
// the baseline instead of going through DidReflow() and
|
||||||
|
// GetBaseline(). This is what nsFrame::GetBaseline() will do anyway.
|
||||||
|
aDesiredSize.ascent = aDesiredSize.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (IsForeignChild(aChildFrame) &&
|
||||||
|
(aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS)) {
|
||||||
|
// use ComputeTightBounds API as aDesiredSize.mBoundingMetrics is not set.
|
||||||
gfxContext* ctx = static_cast<gfxContext*>
|
gfxContext* ctx = static_cast<gfxContext*>
|
||||||
(aReflowState.rendContext->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT));
|
(aReflowState.rendContext->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT));
|
||||||
nsRect r = aChildFrame->ComputeTightBounds(ctx);
|
nsRect r = aChildFrame->ComputeTightBounds(ctx);
|
||||||
aDesiredSize.mBoundingMetrics.leftBearing = r.x;
|
aDesiredSize.mBoundingMetrics.leftBearing = r.x;
|
||||||
aDesiredSize.mBoundingMetrics.rightBearing = r.XMost();
|
aDesiredSize.mBoundingMetrics.rightBearing = r.XMost();
|
||||||
nscoord frameAscent = aDesiredSize.ascent == nsHTMLReflowMetrics::ASK_FOR_BASELINE
|
aDesiredSize.mBoundingMetrics.ascent = aDesiredSize.ascent - r.y;
|
||||||
? aChildFrame->GetBaseline() : aDesiredSize.ascent;
|
aDesiredSize.mBoundingMetrics.descent = r.YMost() - aDesiredSize.ascent;
|
||||||
aDesiredSize.mBoundingMetrics.ascent = frameAscent - r.y;
|
|
||||||
aDesiredSize.mBoundingMetrics.descent = r.YMost() - frameAscent;
|
|
||||||
aDesiredSize.mBoundingMetrics.width = aDesiredSize.width;
|
aDesiredSize.mBoundingMetrics.width = aDesiredSize.width;
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -1047,9 +1047,9 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
|
||||||
|
|
||||||
nsReflowStatus childStatus;
|
nsReflowStatus childStatus;
|
||||||
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
|
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
|
||||||
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags);
|
|
||||||
nsIFrame* childFrame = mFrames.FirstChild();
|
nsIFrame* childFrame = mFrames.FirstChild();
|
||||||
while (childFrame) {
|
while (childFrame) {
|
||||||
|
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags);
|
||||||
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
||||||
childFrame, availSize);
|
childFrame, availSize);
|
||||||
rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
|
rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
|
||||||
|
@ -1101,6 +1101,7 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
|
||||||
childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame);
|
childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame);
|
||||||
if (mathMLFrame) {
|
if (mathMLFrame) {
|
||||||
// retrieve the metrics that was stored at the previous pass
|
// retrieve the metrics that was stored at the previous pass
|
||||||
|
nsHTMLReflowMetrics childDesiredSize;
|
||||||
GetReflowAndBoundingMetricsFor(childFrame,
|
GetReflowAndBoundingMetricsFor(childFrame,
|
||||||
childDesiredSize, childDesiredSize.mBoundingMetrics);
|
childDesiredSize, childDesiredSize.mBoundingMetrics);
|
||||||
|
|
||||||
|
|
|
@ -129,13 +129,13 @@ nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
|
||||||
aDesiredSize.ascent = 0;
|
aDesiredSize.ascent = 0;
|
||||||
aDesiredSize.mBoundingMetrics.Clear();
|
aDesiredSize.mBoundingMetrics.Clear();
|
||||||
|
|
||||||
// ask our children to compute their bounding metrics
|
|
||||||
nsHTMLReflowMetrics childDesiredSize(
|
|
||||||
aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS);
|
|
||||||
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
||||||
PRInt32 count = 0;
|
PRInt32 count = 0;
|
||||||
nsIFrame* childFrame = GetFirstChild(nsnull);
|
nsIFrame* childFrame = GetFirstChild(nsnull);
|
||||||
while (childFrame) {
|
while (childFrame) {
|
||||||
|
// ask our children to compute their bounding metrics
|
||||||
|
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
|
||||||
|
| NS_REFLOW_CALC_BOUNDING_METRICS);
|
||||||
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
||||||
childFrame, availSize);
|
childFrame, availSize);
|
||||||
rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
|
rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
|
||||||
|
|
|
@ -291,8 +291,6 @@ nsMathMLmfencedFrame::doReflow(nsPresContext* aPresContext,
|
||||||
PRInt32 count = 0;
|
PRInt32 count = 0;
|
||||||
nsReflowStatus childStatus;
|
nsReflowStatus childStatus;
|
||||||
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
||||||
nsHTMLReflowMetrics childDesiredSize(
|
|
||||||
aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS);
|
|
||||||
nsIFrame* firstChild = aForFrame->GetFirstChild(nsnull);
|
nsIFrame* firstChild = aForFrame->GetFirstChild(nsnull);
|
||||||
nsIFrame* childFrame = firstChild;
|
nsIFrame* childFrame = firstChild;
|
||||||
nscoord ascent = 0, descent = 0;
|
nscoord ascent = 0, descent = 0;
|
||||||
|
@ -303,6 +301,8 @@ nsMathMLmfencedFrame::doReflow(nsPresContext* aPresContext,
|
||||||
fm->GetMaxDescent(descent);
|
fm->GetMaxDescent(descent);
|
||||||
}
|
}
|
||||||
while (childFrame) {
|
while (childFrame) {
|
||||||
|
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
|
||||||
|
| NS_REFLOW_CALC_BOUNDING_METRICS);
|
||||||
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
||||||
childFrame, availSize);
|
childFrame, availSize);
|
||||||
rv = mathMLFrame->ReflowChild(childFrame, aPresContext, childDesiredSize,
|
rv = mathMLFrame->ReflowChild(childFrame, aPresContext, childDesiredSize,
|
||||||
|
@ -356,6 +356,7 @@ nsMathMLmfencedFrame::doReflow(nsPresContext* aPresContext,
|
||||||
nsIMathMLFrame* mathmlChild;
|
nsIMathMLFrame* mathmlChild;
|
||||||
childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathmlChild);
|
childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathmlChild);
|
||||||
if (mathmlChild) {
|
if (mathmlChild) {
|
||||||
|
nsHTMLReflowMetrics childDesiredSize;
|
||||||
// retrieve the metrics that was stored at the previous pass
|
// retrieve the metrics that was stored at the previous pass
|
||||||
GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize, childDesiredSize.mBoundingMetrics);
|
GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize, childDesiredSize.mBoundingMetrics);
|
||||||
|
|
||||||
|
|
|
@ -160,9 +160,6 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
|
||||||
nsReflowStatus& aStatus)
|
nsReflowStatus& aStatus)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
// ask our children to compute their bounding metrics
|
|
||||||
nsHTMLReflowMetrics childDesiredSize(
|
|
||||||
aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS);
|
|
||||||
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
nsSize availSize(aReflowState.ComputedWidth(), aReflowState.ComputedHeight());
|
||||||
nsReflowStatus childStatus;
|
nsReflowStatus childStatus;
|
||||||
|
|
||||||
|
@ -182,6 +179,9 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
|
||||||
nsHTMLReflowMetrics indexSize;
|
nsHTMLReflowMetrics indexSize;
|
||||||
nsIFrame* childFrame = mFrames.FirstChild();
|
nsIFrame* childFrame = mFrames.FirstChild();
|
||||||
while (childFrame) {
|
while (childFrame) {
|
||||||
|
// ask our children to compute their bounding metrics
|
||||||
|
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
|
||||||
|
| NS_REFLOW_CALC_BOUNDING_METRICS);
|
||||||
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
||||||
childFrame, availSize);
|
childFrame, availSize);
|
||||||
rv = ReflowChild(childFrame, aPresContext,
|
rv = ReflowChild(childFrame, aPresContext,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче