2007-06-12 06:10:23 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2004-04-18 14:30:37 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
1999-09-21 02:12:01 +00:00
|
|
|
* The Original Code is Mozilla MathML Project.
|
2004-04-18 14:30:37 +00:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* The University Of Queensland.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1999
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-09-21 02:12:01 +00:00
|
|
|
* Roger B. Sidje <rbs@maths.uq.edu.au>
|
|
|
|
* David J. Fiddes <D.J.Fiddes@hw.ac.uk>
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2004-04-18 14:30:37 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1999-09-21 02:12:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsFrame.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1999-09-21 02:12:01 +00:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
|
|
|
|
|
|
|
#include "nsMathMLmfencedFrame.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// <mfenced> -- surround content with a pair of fences
|
|
|
|
//
|
|
|
|
|
2005-11-11 02:36:29 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewMathMLmfencedFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-09-21 02:12:01 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsMathMLmfencedFrame(aContext);
|
1999-09-21 02:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsMathMLmfencedFrame::~nsMathMLmfencedFrame()
|
|
|
|
{
|
1999-11-21 22:16:47 +00:00
|
|
|
RemoveFencesAndSeparators();
|
1999-09-21 02:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:57:50 +00:00
|
|
|
nsMathMLmfencedFrame::InheritAutomaticData(nsIFrame* aParent)
|
1999-09-21 02:12:01 +00:00
|
|
|
{
|
2002-02-07 04:38:08 +00:00
|
|
|
// let the base class get the default from our parent
|
2005-02-07 01:57:50 +00:00
|
|
|
nsMathMLContainerFrame::InheritAutomaticData(aParent);
|
1999-11-21 22:16:47 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
return NS_OK;
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-04-10 00:16:29 +00:00
|
|
|
nsMathMLmfencedFrame::SetInitialChildList(nsIAtom* aListName,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
1999-11-21 22:16:47 +00:00
|
|
|
{
|
|
|
|
// First, let the base class do its work
|
2006-04-10 00:16:29 +00:00
|
|
|
nsresult rv = nsMathMLContainerFrame::SetInitialChildList(aListName, aChildList);
|
1999-11-21 22:16:47 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-21 02:12:01 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
// No need to tract the style contexts given to our MathML chars.
|
|
|
|
// The Style System will use Get/SetAdditionalStyleContext() to keep them
|
|
|
|
// up-to-date if dynamic changes arise.
|
2007-03-30 21:11:41 +00:00
|
|
|
return CreateFencesAndSeparators(PresContext());
|
2002-02-07 04:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-09-07 16:49:21 +00:00
|
|
|
nsMathMLmfencedFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
2002-02-07 04:38:08 +00:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-11 21:16:12 +00:00
|
|
|
PRInt32 aModType)
|
2002-02-07 04:38:08 +00:00
|
|
|
{
|
|
|
|
RemoveFencesAndSeparators();
|
2007-03-30 21:11:41 +00:00
|
|
|
CreateFencesAndSeparators(PresContext());
|
2002-02-07 04:38:08 +00:00
|
|
|
|
|
|
|
return nsMathMLContainerFrame::
|
2005-09-07 16:49:21 +00:00
|
|
|
AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
1999-09-21 02:12:01 +00:00
|
|
|
}
|
|
|
|
|
2002-04-02 04:15:22 +00:00
|
|
|
nsresult
|
2005-02-07 01:57:50 +00:00
|
|
|
nsMathMLmfencedFrame::ChildListChanged(PRInt32 aModType)
|
2002-04-02 04:15:22 +00:00
|
|
|
{
|
|
|
|
RemoveFencesAndSeparators();
|
2007-03-30 21:11:41 +00:00
|
|
|
CreateFencesAndSeparators(PresContext());
|
2002-04-02 04:15:22 +00:00
|
|
|
|
2005-02-07 01:57:50 +00:00
|
|
|
return nsMathMLContainerFrame::ChildListChanged(aModType);
|
2002-04-02 04:15:22 +00:00
|
|
|
}
|
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
void
|
|
|
|
nsMathMLmfencedFrame::RemoveFencesAndSeparators()
|
|
|
|
{
|
|
|
|
if (mOpenChar) delete mOpenChar;
|
|
|
|
if (mCloseChar) delete mCloseChar;
|
|
|
|
if (mSeparatorsChar) delete[] mSeparatorsChar;
|
2002-02-07 04:38:08 +00:00
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
mOpenChar = nsnull;
|
|
|
|
mCloseChar = nsnull;
|
|
|
|
mSeparatorsChar = nsnull;
|
|
|
|
mSeparatorsCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsMathMLmfencedFrame::CreateFencesAndSeparators(nsPresContext* aPresContext)
|
1999-11-21 22:16:47 +00:00
|
|
|
{
|
2005-10-28 11:25:24 +00:00
|
|
|
nsAutoString value;
|
2002-02-18 23:16:33 +00:00
|
|
|
PRBool isMutable = PR_FALSE;
|
1999-11-21 22:16:47 +00:00
|
|
|
|
|
|
|
//////////////
|
|
|
|
// see if the opening fence is there ...
|
2006-12-26 17:47:52 +00:00
|
|
|
if (!GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::open,
|
2005-10-28 11:25:24 +00:00
|
|
|
value)) {
|
|
|
|
value = PRUnichar('('); // default as per the MathML REC
|
|
|
|
}
|
|
|
|
else {
|
1999-11-21 22:16:47 +00:00
|
|
|
value.Trim(" ");
|
|
|
|
}
|
2000-02-07 08:51:10 +00:00
|
|
|
|
2005-10-28 11:25:24 +00:00
|
|
|
if (!value.IsEmpty()) {
|
1999-11-21 22:16:47 +00:00
|
|
|
mOpenChar = new nsMathMLChar;
|
|
|
|
if (!mOpenChar) return NS_ERROR_OUT_OF_MEMORY;
|
2005-10-28 11:25:24 +00:00
|
|
|
mOpenChar->SetData(aPresContext, value);
|
|
|
|
isMutable = nsMathMLOperators::IsMutableOperator(value);
|
2002-02-07 04:38:08 +00:00
|
|
|
ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, mOpenChar, isMutable);
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2000-02-07 08:51:10 +00:00
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
//////////////
|
|
|
|
// see if the closing fence is there ...
|
2005-10-28 11:25:24 +00:00
|
|
|
if(!GetAttribute(mContent, mPresentationData.mstyle,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::close, value)) {
|
2005-10-28 11:25:24 +00:00
|
|
|
value = PRUnichar(')'); // default as per the MathML REC
|
|
|
|
}
|
|
|
|
else {
|
1999-11-21 22:16:47 +00:00
|
|
|
value.Trim(" ");
|
|
|
|
}
|
2000-02-07 08:51:10 +00:00
|
|
|
|
2005-10-28 11:25:24 +00:00
|
|
|
if (!value.IsEmpty()) {
|
1999-11-21 22:16:47 +00:00
|
|
|
mCloseChar = new nsMathMLChar;
|
|
|
|
if (!mCloseChar) return NS_ERROR_OUT_OF_MEMORY;
|
2005-10-28 11:25:24 +00:00
|
|
|
mCloseChar->SetData(aPresContext, value);
|
|
|
|
isMutable = nsMathMLOperators::IsMutableOperator(value);
|
2002-02-07 04:38:08 +00:00
|
|
|
ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, mCloseChar, isMutable);
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2000-02-07 08:51:10 +00:00
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
//////////////
|
|
|
|
// see if separators are there ...
|
2005-10-28 11:25:24 +00:00
|
|
|
if(!GetAttribute(mContent, mPresentationData.mstyle,
|
2006-12-26 17:47:52 +00:00
|
|
|
nsGkAtoms::separators_, value)) {
|
2005-10-28 11:25:24 +00:00
|
|
|
value = PRUnichar(','); // default as per the MathML REC
|
|
|
|
}
|
|
|
|
else {
|
1999-11-21 22:16:47 +00:00
|
|
|
value.Trim(" ");
|
|
|
|
}
|
2000-02-07 08:51:10 +00:00
|
|
|
|
2005-10-28 11:25:24 +00:00
|
|
|
mSeparatorsCount = value.Length();
|
1999-11-21 22:16:47 +00:00
|
|
|
if (0 < mSeparatorsCount) {
|
2002-02-18 23:16:33 +00:00
|
|
|
PRInt32 sepCount = mFrames.GetLength() - 1;
|
1999-11-21 22:16:47 +00:00
|
|
|
if (0 < sepCount) {
|
|
|
|
mSeparatorsChar = new nsMathMLChar[sepCount];
|
|
|
|
if (!mSeparatorsChar) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
nsAutoString sepChar;
|
|
|
|
for (PRInt32 i = 0; i < sepCount; i++) {
|
2002-02-07 04:38:08 +00:00
|
|
|
if (i < mSeparatorsCount) {
|
2005-10-28 11:25:24 +00:00
|
|
|
sepChar = value[i];
|
2002-02-07 04:38:08 +00:00
|
|
|
isMutable = nsMathMLOperators::IsMutableOperator(sepChar);
|
|
|
|
}
|
|
|
|
else {
|
2005-10-28 11:25:24 +00:00
|
|
|
sepChar = value[mSeparatorsCount-1];
|
2002-02-07 04:38:08 +00:00
|
|
|
// keep the value of isMutable that was set earlier
|
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
mSeparatorsChar[i].SetData(aPresContext, sepChar);
|
2002-02-07 04:38:08 +00:00
|
|
|
ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, &mSeparatorsChar[i], isMutable);
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2007-11-07 17:16:09 +00:00
|
|
|
mSeparatorsCount = sepCount;
|
|
|
|
} else {
|
|
|
|
// No separators. Note that sepCount can be -1 here, so don't
|
|
|
|
// set mSeparatorsCount to it.
|
|
|
|
mSeparatorsCount = 0;
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-01-26 02:29:17 +00:00
|
|
|
nsMathMLmfencedFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1999-09-21 02:12:01 +00:00
|
|
|
{
|
1999-11-21 22:16:47 +00:00
|
|
|
/////////////
|
2006-01-26 02:29:17 +00:00
|
|
|
// display the content
|
|
|
|
nsresult rv = nsMathMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
////////////
|
2006-01-26 02:29:17 +00:00
|
|
|
// display fences and separators
|
|
|
|
if (mOpenChar) {
|
|
|
|
rv = mOpenChar->Display(aBuilder, this, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mCloseChar) {
|
|
|
|
rv = mCloseChar->Display(aBuilder, this, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
|
|
|
for (PRInt32 i = 0; i < mSeparatorsCount; i++) {
|
|
|
|
rv = mSeparatorsChar[i].Display(aBuilder, this, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
|
1999-11-21 22:16:47 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
2002-01-05 01:15:04 +00:00
|
|
|
{
|
|
|
|
return doReflow(aPresContext, aReflowState, aDesiredSize, aStatus, this,
|
|
|
|
mOpenChar, mCloseChar, mSeparatorsChar, mSeparatorsCount);
|
|
|
|
}
|
|
|
|
|
2008-03-14 05:02:49 +00:00
|
|
|
/* virtual */ nscoord
|
|
|
|
nsMathMLmfencedFrame::GetIntrinsicWidth(nsIRenderingContext* aRenderingContext)
|
|
|
|
{
|
|
|
|
return doGetIntrinsicWidth(aRenderingContext, this, mOpenChar, mCloseChar,
|
|
|
|
mSeparatorsChar, mSeparatorsCount);
|
|
|
|
}
|
|
|
|
|
2002-01-05 01:15:04 +00:00
|
|
|
// exported routine that both mfenced and mfrac share.
|
|
|
|
// mfrac uses this when its bevelled attribute is set.
|
|
|
|
/*static*/ nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsMathMLmfencedFrame::doReflow(nsPresContext* aPresContext,
|
2002-01-05 01:15:04 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsReflowStatus& aStatus,
|
2008-02-26 04:19:36 +00:00
|
|
|
nsMathMLContainerFrame* aForFrame,
|
2002-01-05 01:15:04 +00:00
|
|
|
nsMathMLChar* aOpenChar,
|
|
|
|
nsMathMLChar* aCloseChar,
|
|
|
|
nsMathMLChar* aSeparatorsChar,
|
|
|
|
PRInt32 aSeparatorsCount)
|
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
{
|
2000-03-28 09:38:24 +00:00
|
|
|
nsresult rv;
|
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
2007-01-23 04:06:56 +00:00
|
|
|
aDesiredSize.ascent = 0;
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.mBoundingMetrics.Clear();
|
1999-11-21 22:16:47 +00:00
|
|
|
|
2002-02-27 01:35:27 +00:00
|
|
|
PRInt32 i;
|
|
|
|
nsCOMPtr<nsIFontMetrics> fm;
|
2008-01-09 09:38:28 +00:00
|
|
|
const nsStyleFont* font = aForFrame->GetStyleFont();
|
2008-12-04 16:09:53 +00:00
|
|
|
aReflowState.rendContext->SetFont(font->mFont, nsnull,
|
|
|
|
aPresContext->GetUserFontSet());
|
2002-02-27 01:35:27 +00:00
|
|
|
aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm));
|
|
|
|
nscoord axisHeight, em;
|
|
|
|
GetAxisHeight(*aReflowState.rendContext, fm, axisHeight);
|
|
|
|
GetEmHeight(fm, em);
|
|
|
|
// leading to be left at the top and the bottom of stretched chars
|
|
|
|
nscoord leading = NSToCoordRound(0.2f * em);
|
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
/////////////
|
|
|
|
// Reflow children
|
|
|
|
// Asking each child to cache its bounding metrics
|
1999-11-21 22:16:47 +00:00
|
|
|
|
2000-05-26 05:56:23 +00:00
|
|
|
// Note that we don't use the base method nsMathMLContainerFrame::Reflow()
|
|
|
|
// because we want to stretch our fences, separators and stretchy frames using
|
|
|
|
// the *same* initial aDesiredSize.mBoundingMetrics. If we were to use the base
|
|
|
|
// method here, our stretchy frames will be stretched and placed, and we may
|
|
|
|
// end up stretching our fences/separators with a different aDesiredSize.
|
2002-05-01 05:47:15 +00:00
|
|
|
// XXX The above decision was revisited in bug 121748 and this code can be
|
|
|
|
// refactored to use nsMathMLContainerFrame::Reflow() at some stage.
|
2000-05-26 05:56:23 +00:00
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
nsReflowStatus childStatus;
|
2008-01-15 01:13:21 +00:00
|
|
|
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame* firstChild = aForFrame->GetFirstChild(nsnull);
|
2002-02-15 14:39:50 +00:00
|
|
|
nsIFrame* childFrame = firstChild;
|
2007-01-23 04:06:56 +00:00
|
|
|
nscoord ascent = 0, descent = 0;
|
2002-02-27 01:35:27 +00:00
|
|
|
if (firstChild || aOpenChar || aCloseChar || aSeparatorsCount > 0) {
|
|
|
|
// We use the ASCII metrics to get our minimum height. This way, if we have
|
|
|
|
// borders or a background, they will fit better with other elements on the line
|
2007-01-23 04:06:56 +00:00
|
|
|
fm->GetMaxAscent(ascent);
|
|
|
|
fm->GetMaxDescent(descent);
|
2002-02-27 01:35:27 +00:00
|
|
|
}
|
1999-11-21 22:16:47 +00:00
|
|
|
while (childFrame) {
|
2007-12-03 00:54:23 +00:00
|
|
|
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
|
|
|
|
| NS_REFLOW_CALC_BOUNDING_METRICS);
|
2001-02-23 16:10:51 +00:00
|
|
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
childFrame, availSize);
|
2008-02-26 04:19:36 +00:00
|
|
|
rv = aForFrame->ReflowChild(childFrame, aPresContext, childDesiredSize,
|
|
|
|
childReflowState, childStatus);
|
2001-02-23 16:10:51 +00:00
|
|
|
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
|
2007-03-02 10:55:55 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Call DidReflow() for the child frames we successfully did reflow.
|
2008-02-26 04:19:36 +00:00
|
|
|
aForFrame->DidReflowChildren(firstChild, childFrame);
|
2007-03-02 10:55:55 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2001-02-23 16:10:51 +00:00
|
|
|
|
2008-02-26 04:19:36 +00:00
|
|
|
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
|
|
|
|
childDesiredSize.mBoundingMetrics);
|
2001-02-23 16:10:51 +00:00
|
|
|
|
2002-01-05 01:15:04 +00:00
|
|
|
// compute the bounding metrics right now for mfrac
|
2007-01-23 04:06:56 +00:00
|
|
|
nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
|
|
|
|
if (descent < childDescent)
|
|
|
|
descent = childDescent;
|
|
|
|
if (ascent < childDesiredSize.ascent)
|
|
|
|
ascent = childDesiredSize.ascent;
|
2008-01-03 04:32:12 +00:00
|
|
|
aDesiredSize.mBoundingMetrics += childDesiredSize.mBoundingMetrics;
|
2002-01-05 01:15:04 +00:00
|
|
|
|
2003-07-08 11:00:00 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
/////////////
|
|
|
|
// Ask stretchy children to stretch themselves
|
2002-01-05 01:15:04 +00:00
|
|
|
|
|
|
|
nsBoundingMetrics containerSize;
|
1999-11-21 22:16:47 +00:00
|
|
|
nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;
|
2002-01-05 01:15:04 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
nsPresentationData presentationData;
|
2008-02-26 04:19:36 +00:00
|
|
|
aForFrame->GetPresentationData(presentationData);
|
2002-02-07 04:38:08 +00:00
|
|
|
if (!NS_MATHML_WILL_STRETCH_ALL_CHILDREN_VERTICALLY(presentationData.flags)) {
|
2002-01-05 01:15:04 +00:00
|
|
|
// case when the call is made for mfrac, we only need to stretch the '/' separator
|
|
|
|
containerSize = aDesiredSize.mBoundingMetrics; // computed earlier
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// case when the call is made for mfenced
|
2008-02-26 04:19:36 +00:00
|
|
|
aForFrame->GetPreferredStretchSize(*aReflowState.rendContext,
|
|
|
|
0, /* i.e., without embellishments */
|
|
|
|
stretchDir, containerSize);
|
2002-02-15 14:39:50 +00:00
|
|
|
childFrame = firstChild;
|
2002-01-05 01:15:04 +00:00
|
|
|
while (childFrame) {
|
2009-01-12 19:20:59 +00:00
|
|
|
nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
|
2002-02-07 04:38:08 +00:00
|
|
|
if (mathmlChild) {
|
2007-12-03 00:54:23 +00:00
|
|
|
nsHTMLReflowMetrics childDesiredSize;
|
2002-01-05 01:15:04 +00:00
|
|
|
// retrieve the metrics that was stored at the previous pass
|
2008-02-26 04:19:36 +00:00
|
|
|
GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
|
|
|
|
childDesiredSize.mBoundingMetrics);
|
2002-01-05 01:15:04 +00:00
|
|
|
|
2005-02-07 01:57:50 +00:00
|
|
|
mathmlChild->Stretch(*aReflowState.rendContext,
|
2002-01-05 01:15:04 +00:00
|
|
|
stretchDir, containerSize, childDesiredSize);
|
|
|
|
// store the updated metrics
|
2008-02-26 04:19:36 +00:00
|
|
|
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
|
|
|
|
childDesiredSize.mBoundingMetrics);
|
2002-01-05 01:15:04 +00:00
|
|
|
|
2007-01-23 04:06:56 +00:00
|
|
|
nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
|
|
|
|
if (descent < childDescent)
|
|
|
|
descent = childDescent;
|
|
|
|
if (ascent < childDesiredSize.ascent)
|
|
|
|
ascent = childDesiredSize.ascent;
|
2002-01-05 01:15:04 +00:00
|
|
|
}
|
2003-07-08 11:00:00 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2002-05-01 05:47:15 +00:00
|
|
|
// bug 121748: for surrounding fences & separators, use a size that covers everything
|
2008-02-26 04:19:36 +00:00
|
|
|
aForFrame->GetPreferredStretchSize(*aReflowState.rendContext,
|
|
|
|
STRETCH_CONSIDER_EMBELLISHMENTS,
|
|
|
|
stretchDir, containerSize);
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
// Prepare the opening fence, separators, and closing fence, and
|
2000-03-28 09:38:24 +00:00
|
|
|
// adjust the origin of children.
|
1999-11-21 22:16:47 +00:00
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
// we need to center around the axis
|
2002-02-15 14:39:50 +00:00
|
|
|
if (firstChild) { // do nothing for an empty <mfenced></mfenced>
|
|
|
|
nscoord delta = PR_MAX(containerSize.ascent - axisHeight,
|
|
|
|
containerSize.descent + axisHeight);
|
|
|
|
containerSize.ascent = delta + axisHeight;
|
|
|
|
containerSize.descent = delta - axisHeight;
|
|
|
|
}
|
1999-11-21 22:16:47 +00:00
|
|
|
|
|
|
|
/////////////////
|
|
|
|
// opening fence ...
|
2002-01-05 01:15:04 +00:00
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, aOpenChar,
|
2008-01-09 09:38:28 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel,
|
2007-01-23 04:06:56 +00:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent);
|
1999-11-21 22:16:47 +00:00
|
|
|
/////////////////
|
|
|
|
// separators ...
|
2002-01-05 01:15:04 +00:00
|
|
|
for (i = 0; i < aSeparatorsCount; i++) {
|
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, &aSeparatorsChar[i],
|
2008-01-09 09:38:28 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
|
2007-01-23 04:06:56 +00:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent);
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
/////////////////
|
|
|
|
// closing fence ...
|
2002-01-05 01:15:04 +00:00
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, aCloseChar,
|
2008-01-09 09:38:28 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
|
2007-01-23 04:06:56 +00:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent);
|
1999-11-21 22:16:47 +00:00
|
|
|
|
|
|
|
//////////////////
|
2000-03-28 09:38:24 +00:00
|
|
|
// Adjust the origins of each child.
|
|
|
|
// and update our bounding metrics
|
|
|
|
|
|
|
|
i = 0;
|
2000-05-26 05:56:23 +00:00
|
|
|
nscoord dx = 0;
|
2000-03-28 09:38:24 +00:00
|
|
|
nsBoundingMetrics bm;
|
|
|
|
PRBool firstTime = PR_TRUE;
|
2002-01-05 01:15:04 +00:00
|
|
|
if (aOpenChar) {
|
2007-01-23 04:06:56 +00:00
|
|
|
PlaceChar(aOpenChar, ascent, bm, dx);
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.mBoundingMetrics = bm;
|
2000-03-28 09:38:24 +00:00
|
|
|
firstTime = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-02-15 14:39:50 +00:00
|
|
|
childFrame = firstChild;
|
1999-11-21 22:16:47 +00:00
|
|
|
while (childFrame) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsHTMLReflowMetrics childSize;
|
2001-02-23 16:10:51 +00:00
|
|
|
GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);
|
|
|
|
if (firstTime) {
|
|
|
|
firstTime = PR_FALSE;
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.mBoundingMetrics = bm;
|
2001-02-23 16:10:51 +00:00
|
|
|
}
|
|
|
|
else
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.mBoundingMetrics += bm;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2008-02-26 04:19:36 +00:00
|
|
|
aForFrame->FinishReflowChild(childFrame, aPresContext, nsnull, childSize,
|
2007-01-23 04:06:56 +00:00
|
|
|
dx, ascent - childSize.ascent, 0);
|
2001-02-23 16:10:51 +00:00
|
|
|
dx += childSize.width;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2002-01-05 01:15:04 +00:00
|
|
|
if (i < aSeparatorsCount) {
|
2007-01-23 04:06:56 +00:00
|
|
|
PlaceChar(&aSeparatorsChar[i], ascent, bm, dx);
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.mBoundingMetrics += bm;
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2001-02-23 16:10:51 +00:00
|
|
|
i++;
|
|
|
|
|
2003-07-08 11:00:00 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2002-01-05 01:15:04 +00:00
|
|
|
if (aCloseChar) {
|
2007-01-23 04:06:56 +00:00
|
|
|
PlaceChar(aCloseChar, ascent, bm, dx);
|
2000-03-28 09:38:24 +00:00
|
|
|
if (firstTime)
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.mBoundingMetrics = bm;
|
2000-03-28 09:38:24 +00:00
|
|
|
else
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.mBoundingMetrics += bm;
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.width = aDesiredSize.mBoundingMetrics.width;
|
2007-01-23 04:06:56 +00:00
|
|
|
aDesiredSize.height = ascent + descent;
|
|
|
|
aDesiredSize.ascent = ascent;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2008-02-26 04:19:36 +00:00
|
|
|
aForFrame->SetBoundingMetrics(aDesiredSize.mBoundingMetrics);
|
|
|
|
aForFrame->SetReference(nsPoint(0, aDesiredSize.ascent));
|
2002-01-05 01:15:04 +00:00
|
|
|
|
2005-09-16 00:39:27 +00:00
|
|
|
// see if we should fix the spacing
|
2008-02-26 04:19:36 +00:00
|
|
|
aForFrame->FixInterFrameSpacing(aDesiredSize);
|
|
|
|
|
|
|
|
// Finished with these:
|
|
|
|
aForFrame->ClearSavedChildMetrics();
|
2005-09-16 00:39:27 +00:00
|
|
|
|
2007-12-28 23:04:19 +00:00
|
|
|
// Set our overflow area
|
2008-02-26 04:19:36 +00:00
|
|
|
aForFrame->GatherAndStoreOverflow(&aDesiredSize);
|
2007-12-28 23:04:19 +00:00
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1999-11-21 22:16:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-14 05:02:49 +00:00
|
|
|
static void
|
|
|
|
GetCharSpacing(nsMathMLChar* aMathMLChar,
|
|
|
|
nsOperatorFlags aForm,
|
|
|
|
PRInt32 aScriptLevel,
|
|
|
|
nscoord em,
|
|
|
|
nscoord& aLeftSpace,
|
|
|
|
nscoord& aRightSpace)
|
|
|
|
{
|
|
|
|
nsAutoString data;
|
|
|
|
aMathMLChar->GetData(data);
|
|
|
|
nsOperatorFlags flags = 0;
|
|
|
|
float lspace = 0.0f;
|
|
|
|
float rspace = 0.0f;
|
|
|
|
PRBool found = nsMathMLOperators::LookupOperator(data, aForm,
|
|
|
|
&flags, &lspace, &rspace);
|
|
|
|
|
|
|
|
// We don't want extra space when we are a script
|
|
|
|
if (found && aScriptLevel > 0) {
|
|
|
|
lspace /= 2.0f;
|
|
|
|
rspace /= 2.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
aLeftSpace = NSToCoordRound(lspace * em);
|
|
|
|
aRightSpace = NSToCoordRound(rspace * em);
|
|
|
|
}
|
|
|
|
|
2000-05-26 05:56:23 +00:00
|
|
|
// helper functions to perform the common task of formatting our chars
|
2002-01-05 01:15:04 +00:00
|
|
|
/*static*/ nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsMathMLmfencedFrame::ReflowChar(nsPresContext* aPresContext,
|
1999-11-21 22:16:47 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
nsMathMLChar* aMathMLChar,
|
|
|
|
nsOperatorFlags aForm,
|
|
|
|
PRInt32 aScriptLevel,
|
2000-03-28 09:38:24 +00:00
|
|
|
nscoord axisHeight,
|
2002-02-27 01:35:27 +00:00
|
|
|
nscoord leading,
|
1999-11-21 22:16:47 +00:00
|
|
|
nscoord em,
|
2000-03-28 09:38:24 +00:00
|
|
|
nsBoundingMetrics& aContainerSize,
|
2007-01-23 04:06:56 +00:00
|
|
|
nscoord& aAscent,
|
|
|
|
nscoord& aDescent)
|
1999-11-21 22:16:47 +00:00
|
|
|
{
|
|
|
|
if (aMathMLChar && 0 < aMathMLChar->Length()) {
|
2008-03-14 05:02:49 +00:00
|
|
|
nscoord leftSpace;
|
|
|
|
nscoord rightSpace;
|
|
|
|
GetCharSpacing(aMathMLChar, aForm, aScriptLevel, em, leftSpace, rightSpace);
|
2000-07-10 13:57:52 +00:00
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
// stretch the char to the appropriate height if it is not big enough.
|
|
|
|
nsBoundingMetrics charSize;
|
2000-07-25 00:08:15 +00:00
|
|
|
nsresult res = aMathMLChar->Stretch(aPresContext, aRenderingContext,
|
|
|
|
NS_STRETCH_DIRECTION_VERTICAL,
|
|
|
|
aContainerSize, charSize);
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2002-02-27 01:35:27 +00:00
|
|
|
if (NS_STRETCH_DIRECTION_UNSUPPORTED != aMathMLChar->GetStretchDirection()) {
|
2000-03-28 09:38:24 +00:00
|
|
|
// has changed... so center the char around the axis
|
|
|
|
nscoord height = charSize.ascent + charSize.descent;
|
|
|
|
charSize.ascent = height/2 + axisHeight;
|
|
|
|
charSize.descent = height - charSize.ascent;
|
|
|
|
}
|
|
|
|
else {
|
2002-01-05 01:15:04 +00:00
|
|
|
// either it hasn't changed or stretching the char failed (i.e.,
|
|
|
|
// GetBoundingMetrics failed)
|
2002-02-27 01:35:27 +00:00
|
|
|
leading = 0;
|
2002-01-05 01:15:04 +00:00
|
|
|
if (NS_FAILED(res)) {
|
2008-03-14 05:02:49 +00:00
|
|
|
nsAutoString data;
|
|
|
|
aMathMLChar->GetData(data);
|
2002-01-05 01:15:04 +00:00
|
|
|
nsTextDimensions dimensions;
|
2006-06-26 22:18:23 +00:00
|
|
|
aRenderingContext.GetTextDimensions(data.get(), data.Length(), dimensions);
|
2002-01-05 01:15:04 +00:00
|
|
|
charSize.ascent = dimensions.ascent;
|
|
|
|
charSize.descent = dimensions.descent;
|
|
|
|
charSize.width = dimensions.width;
|
|
|
|
// Set this as the bounding metrics of the MathMLChar to leave
|
|
|
|
// the necessary room to paint the char.
|
|
|
|
aMathMLChar->SetBoundingMetrics(charSize);
|
2000-07-25 00:08:15 +00:00
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
|
|
|
|
2007-01-23 04:06:56 +00:00
|
|
|
if (aAscent < charSize.ascent + leading)
|
|
|
|
aAscent = charSize.ascent + leading;
|
|
|
|
if (aDescent < charSize.descent + leading)
|
|
|
|
aDescent = charSize.descent + leading;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
// account the spacing
|
2008-03-14 05:02:49 +00:00
|
|
|
charSize.width += leftSpace + rightSpace;
|
1999-11-21 22:16:47 +00:00
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
// x-origin is used to store lspace ...
|
|
|
|
// y-origin is used to stored the ascent ...
|
2008-03-14 05:02:49 +00:00
|
|
|
aMathMLChar->SetRect(nsRect(leftSpace,
|
2000-03-28 09:38:24 +00:00
|
|
|
charSize.ascent, charSize.width,
|
|
|
|
charSize.ascent + charSize.descent));
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-21 22:16:47 +00:00
|
|
|
|
2002-01-05 01:15:04 +00:00
|
|
|
/*static*/ void
|
2000-05-26 05:56:23 +00:00
|
|
|
nsMathMLmfencedFrame::PlaceChar(nsMathMLChar* aMathMLChar,
|
|
|
|
nscoord aDesiredAscent,
|
|
|
|
nsBoundingMetrics& bm,
|
|
|
|
nscoord& dx)
|
|
|
|
{
|
|
|
|
aMathMLChar->GetBoundingMetrics(bm);
|
|
|
|
|
|
|
|
// the char's x-origin was used to store lspace ...
|
2000-07-25 00:08:15 +00:00
|
|
|
// the char's y-origin was used to store the ascent ...
|
2008-03-14 05:02:49 +00:00
|
|
|
// the char's width was used to store the advance with (with spacing) ...
|
2000-05-26 05:56:23 +00:00
|
|
|
nsRect rect;
|
|
|
|
aMathMLChar->GetRect(rect);
|
2002-02-27 01:35:27 +00:00
|
|
|
|
2000-05-26 05:56:23 +00:00
|
|
|
nscoord dy = aDesiredAscent - rect.y;
|
2002-02-27 01:35:27 +00:00
|
|
|
if (aMathMLChar->GetStretchDirection() != NS_STRETCH_DIRECTION_UNSUPPORTED) {
|
2000-05-26 05:56:23 +00:00
|
|
|
// the stretchy char will be centered around the axis
|
|
|
|
// so we adjust the returned bounding metrics accordingly
|
|
|
|
bm.descent = (bm.ascent + bm.descent) - rect.y;
|
|
|
|
bm.ascent = rect.y;
|
|
|
|
}
|
|
|
|
|
2002-02-27 01:35:27 +00:00
|
|
|
aMathMLChar->SetRect(nsRect(dx + rect.x, dy, bm.width, rect.height));
|
2000-05-26 05:56:23 +00:00
|
|
|
|
|
|
|
bm.leftBearing += rect.x;
|
|
|
|
bm.rightBearing += rect.x;
|
2002-02-27 01:35:27 +00:00
|
|
|
|
2000-05-26 05:56:23 +00:00
|
|
|
// return rect.width since it includes lspace and rspace
|
|
|
|
bm.width = rect.width;
|
|
|
|
dx += rect.width;
|
|
|
|
}
|
|
|
|
|
2008-03-14 05:02:49 +00:00
|
|
|
static nscoord
|
|
|
|
GetMaxCharWidth(nsPresContext* aPresContext,
|
|
|
|
nsIRenderingContext* aRenderingContext,
|
|
|
|
nsMathMLChar* aMathMLChar,
|
|
|
|
nsOperatorFlags aForm,
|
|
|
|
PRInt32 aScriptLevel,
|
|
|
|
nscoord em)
|
|
|
|
{
|
|
|
|
nscoord width = aMathMLChar->GetMaxWidth(aPresContext, *aRenderingContext);
|
|
|
|
|
|
|
|
if (0 < aMathMLChar->Length()) {
|
|
|
|
nscoord leftSpace;
|
|
|
|
nscoord rightSpace;
|
|
|
|
GetCharSpacing(aMathMLChar, aForm, aScriptLevel, em, leftSpace, rightSpace);
|
|
|
|
|
|
|
|
width += leftSpace + rightSpace;
|
|
|
|
}
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
|
|
|
nsMathMLmfencedFrame::doGetIntrinsicWidth(nsIRenderingContext* aRenderingContext,
|
|
|
|
nsMathMLContainerFrame* aForFrame,
|
|
|
|
nsMathMLChar* aOpenChar,
|
|
|
|
nsMathMLChar* aCloseChar,
|
|
|
|
nsMathMLChar* aSeparatorsChar,
|
|
|
|
PRInt32 aSeparatorsCount)
|
|
|
|
{
|
|
|
|
nscoord width = 0;
|
|
|
|
|
|
|
|
nsPresContext* presContext = aForFrame->PresContext();
|
|
|
|
const nsStyleFont* font = aForFrame->GetStyleFont();
|
|
|
|
nsCOMPtr<nsIFontMetrics> fm = presContext->GetMetricsFor(font->mFont);
|
|
|
|
nscoord em;
|
|
|
|
GetEmHeight(fm, em);
|
|
|
|
|
|
|
|
if (aOpenChar) {
|
|
|
|
width +=
|
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, aOpenChar,
|
|
|
|
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 i = 0;
|
|
|
|
nsIFrame* childFrame = aForFrame->GetFirstChild(nsnull);
|
|
|
|
while (childFrame) {
|
|
|
|
// XXX This includes margin while Reflow currently doesn't consider
|
|
|
|
// margin, so we may end up with too much space, but, with stretchy
|
|
|
|
// characters, this is an approximation anyway.
|
|
|
|
width += nsLayoutUtils::IntrinsicForContainer(aRenderingContext, childFrame,
|
|
|
|
nsLayoutUtils::PREF_WIDTH);
|
|
|
|
|
|
|
|
if (i < aSeparatorsCount) {
|
|
|
|
width +=
|
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, &aSeparatorsChar[i],
|
|
|
|
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aCloseChar) {
|
|
|
|
width +=
|
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, aCloseChar,
|
|
|
|
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2005-09-16 00:39:27 +00:00
|
|
|
nscoord
|
|
|
|
nsMathMLmfencedFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
|
|
|
|
{
|
|
|
|
nscoord gap = nsMathMLContainerFrame::FixInterFrameSpacing(aDesiredSize);
|
|
|
|
if (!gap) return 0;
|
|
|
|
|
|
|
|
nsRect rect;
|
|
|
|
if (mOpenChar) {
|
|
|
|
mOpenChar->GetRect(rect);
|
|
|
|
rect.MoveBy(gap, 0);
|
|
|
|
mOpenChar->SetRect(rect);
|
|
|
|
}
|
|
|
|
if (mCloseChar) {
|
|
|
|
mCloseChar->GetRect(rect);
|
|
|
|
rect.MoveBy(gap, 0);
|
|
|
|
mCloseChar->SetRect(rect);
|
|
|
|
}
|
|
|
|
for (PRInt32 i = 0; i < mSeparatorsCount; i++) {
|
|
|
|
mSeparatorsChar[i].GetRect(rect);
|
|
|
|
rect.MoveBy(gap, 0);
|
|
|
|
mSeparatorsChar[i].SetRect(rect);
|
|
|
|
}
|
|
|
|
return gap;
|
|
|
|
}
|
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
// ----------------------
|
|
|
|
// the Style System will use these to pass the proper style context to our MathMLChar
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext*
|
|
|
|
nsMathMLmfencedFrame::GetAdditionalStyleContext(PRInt32 aIndex) const
|
2000-03-28 09:38:24 +00:00
|
|
|
{
|
|
|
|
PRInt32 openIndex = -1;
|
|
|
|
PRInt32 closeIndex = -1;
|
|
|
|
PRInt32 lastIndex = mSeparatorsCount-1;
|
|
|
|
|
|
|
|
if (mOpenChar) {
|
|
|
|
lastIndex++;
|
|
|
|
openIndex = lastIndex;
|
|
|
|
}
|
|
|
|
if (mCloseChar) {
|
|
|
|
lastIndex++;
|
|
|
|
closeIndex = lastIndex;
|
|
|
|
}
|
|
|
|
if (aIndex < 0 || aIndex > lastIndex) {
|
2003-02-22 00:32:13 +00:00
|
|
|
return nsnull;
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aIndex < mSeparatorsCount) {
|
2003-02-22 00:32:13 +00:00
|
|
|
return mSeparatorsChar[aIndex].GetStyleContext();
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
|
|
|
else if (aIndex == openIndex) {
|
2003-02-22 00:32:13 +00:00
|
|
|
return mOpenChar->GetStyleContext();
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
|
|
|
else if (aIndex == closeIndex) {
|
2003-02-22 00:32:13 +00:00
|
|
|
return mCloseChar->GetStyleContext();
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
2003-02-22 00:32:13 +00:00
|
|
|
return nsnull;
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
2000-03-28 09:38:24 +00:00
|
|
|
nsMathMLmfencedFrame::SetAdditionalStyleContext(PRInt32 aIndex,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aStyleContext)
|
2000-03-28 09:38:24 +00:00
|
|
|
{
|
|
|
|
PRInt32 openIndex = -1;
|
|
|
|
PRInt32 closeIndex = -1;
|
|
|
|
PRInt32 lastIndex = mSeparatorsCount-1;
|
|
|
|
|
|
|
|
if (mOpenChar) {
|
|
|
|
lastIndex++;
|
|
|
|
openIndex = lastIndex;
|
|
|
|
}
|
|
|
|
if (mCloseChar) {
|
|
|
|
lastIndex++;
|
|
|
|
closeIndex = lastIndex;
|
|
|
|
}
|
|
|
|
if (aIndex < 0 || aIndex > lastIndex) {
|
2003-02-22 00:32:13 +00:00
|
|
|
return;
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aIndex < mSeparatorsCount) {
|
|
|
|
mSeparatorsChar[aIndex].SetStyleContext(aStyleContext);
|
|
|
|
}
|
|
|
|
else if (aIndex == openIndex) {
|
|
|
|
mOpenChar->SetStyleContext(aStyleContext);
|
|
|
|
}
|
|
|
|
else if (aIndex == closeIndex) {
|
|
|
|
mCloseChar->SetStyleContext(aStyleContext);
|
|
|
|
}
|
1999-09-21 02:12:01 +00:00
|
|
|
}
|