2007-06-12 10:10:23 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2004-04-18 18:30:37 +04: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 06:12:01 +04:00
|
|
|
* The Original Code is Mozilla MathML Project.
|
2004-04-18 18:30:37 +04: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 06:12:01 +04:00
|
|
|
* Roger B. Sidje <rbs@maths.uq.edu.au>
|
|
|
|
* David J. Fiddes <D.J.Fiddes@hw.ac.uk>
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2009-10-07 13:31:45 +04:00
|
|
|
* Frederic Wang <fred.wang@free.fr>
|
2011-07-11 08:11:28 +04:00
|
|
|
* Florian Scholz <elchi3@elchi3.de>
|
2004-04-18 18:30:37 +04: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 06:12:01 +04:00
|
|
|
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1999-09-21 06:12:01 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
1999-09-21 06:12:01 +04:00
|
|
|
|
|
|
|
#include "nsMathMLmfencedFrame.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// <mfenced> -- surround content with a pair of fences
|
|
|
|
//
|
|
|
|
|
2005-11-11 05:36:29 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewMathMLmfencedFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-09-21 06:12:01 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsMathMLmfencedFrame(aContext);
|
1999-09-21 06:12:01 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmfencedFrame)
|
|
|
|
|
1999-09-21 06:12:01 +04:00
|
|
|
nsMathMLmfencedFrame::~nsMathMLmfencedFrame()
|
|
|
|
{
|
1999-11-22 01:16:47 +03:00
|
|
|
RemoveFencesAndSeparators();
|
1999-09-21 06:12:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLmfencedFrame::InheritAutomaticData(nsIFrame* aParent)
|
1999-09-21 06:12:01 +04:00
|
|
|
{
|
2002-02-07 07:38:08 +03:00
|
|
|
// let the base class get the default from our parent
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLContainerFrame::InheritAutomaticData(aParent);
|
1999-11-22 01:16:47 +03:00
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY;
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2011-05-13 01:31:48 +04:00
|
|
|
RemoveFencesAndSeparators();
|
|
|
|
CreateFencesAndSeparators(PresContext());
|
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
return NS_OK;
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-04-10 04:16:29 +04:00
|
|
|
nsMathMLmfencedFrame::SetInitialChildList(nsIAtom* aListName,
|
2009-07-28 16:53:20 +04:00
|
|
|
nsFrameList& aChildList)
|
1999-11-22 01:16:47 +03:00
|
|
|
{
|
|
|
|
// First, let the base class do its work
|
2006-04-10 04:16:29 +04:00
|
|
|
nsresult rv = nsMathMLContainerFrame::SetInitialChildList(aListName, aChildList);
|
1999-11-22 01:16:47 +03:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-21 06:12:01 +04:00
|
|
|
|
2011-05-19 03:56:14 +04:00
|
|
|
// InheritAutomaticData will not get called if our parent is not a mathml
|
|
|
|
// frame, so initialize NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY for
|
|
|
|
// GetPreferredStretchSize() from Reflow().
|
|
|
|
mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY;
|
2009-08-17 01:53:42 +04:00
|
|
|
// No need to track the style contexts given to our MathML chars.
|
2002-02-07 07:38:08 +03:00
|
|
|
// The Style System will use Get/SetAdditionalStyleContext() to keep them
|
|
|
|
// up-to-date if dynamic changes arise.
|
2010-11-05 13:57:39 +03:00
|
|
|
CreateFencesAndSeparators(PresContext());
|
|
|
|
return NS_OK;
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-09-07 20:49:21 +04:00
|
|
|
nsMathMLmfencedFrame::AttributeChanged(PRInt32 aNameSpaceID,
|
2002-02-07 07:38:08 +03:00
|
|
|
nsIAtom* aAttribute,
|
2003-07-12 01:16:12 +04:00
|
|
|
PRInt32 aModType)
|
2002-02-07 07:38:08 +03:00
|
|
|
{
|
|
|
|
RemoveFencesAndSeparators();
|
2007-03-31 01:11:41 +04:00
|
|
|
CreateFencesAndSeparators(PresContext());
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
return nsMathMLContainerFrame::
|
2005-09-07 20:49:21 +04:00
|
|
|
AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
1999-09-21 06:12:01 +04:00
|
|
|
}
|
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
nsresult
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLmfencedFrame::ChildListChanged(PRInt32 aModType)
|
2002-04-02 08:15:22 +04:00
|
|
|
{
|
|
|
|
RemoveFencesAndSeparators();
|
2007-03-31 01:11:41 +04:00
|
|
|
CreateFencesAndSeparators(PresContext());
|
2002-04-02 08:15:22 +04:00
|
|
|
|
2005-02-07 04:57:50 +03:00
|
|
|
return nsMathMLContainerFrame::ChildListChanged(aModType);
|
2002-04-02 08:15:22 +04:00
|
|
|
}
|
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
void
|
|
|
|
nsMathMLmfencedFrame::RemoveFencesAndSeparators()
|
|
|
|
{
|
2011-05-17 18:01:36 +04:00
|
|
|
delete mOpenChar;
|
|
|
|
delete mCloseChar;
|
1999-11-22 01:16:47 +03:00
|
|
|
if (mSeparatorsChar) delete[] mSeparatorsChar;
|
2002-02-07 07:38:08 +03:00
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
mOpenChar = nsnull;
|
|
|
|
mCloseChar = nsnull;
|
|
|
|
mSeparatorsChar = nsnull;
|
|
|
|
mSeparatorsCount = 0;
|
|
|
|
}
|
|
|
|
|
2010-11-05 13:57:39 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmfencedFrame::CreateFencesAndSeparators(nsPresContext* aPresContext)
|
1999-11-22 01:16:47 +03:00
|
|
|
{
|
2005-10-28 15:25:24 +04:00
|
|
|
nsAutoString value;
|
2002-02-19 02:16:33 +03:00
|
|
|
PRBool isMutable = PR_FALSE;
|
1999-11-22 01:16:47 +03:00
|
|
|
|
|
|
|
//////////////
|
|
|
|
// see if the opening fence is there ...
|
2006-12-26 20:47:52 +03:00
|
|
|
if (!GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::open,
|
2005-10-28 15:25:24 +04:00
|
|
|
value)) {
|
|
|
|
value = PRUnichar('('); // default as per the MathML REC
|
2010-11-05 13:57:51 +03:00
|
|
|
} else {
|
|
|
|
value.CompressWhitespace();
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2000-02-07 11:51:10 +03:00
|
|
|
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
1999-11-22 01:16:47 +03:00
|
|
|
mOpenChar = new nsMathMLChar;
|
2005-10-28 15:25:24 +04:00
|
|
|
mOpenChar->SetData(aPresContext, value);
|
|
|
|
isMutable = nsMathMLOperators::IsMutableOperator(value);
|
2002-02-07 07:38:08 +03:00
|
|
|
ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, mOpenChar, isMutable);
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2000-02-07 11:51:10 +03:00
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
//////////////
|
|
|
|
// see if the closing fence is there ...
|
2005-10-28 15:25:24 +04:00
|
|
|
if(!GetAttribute(mContent, mPresentationData.mstyle,
|
2006-12-26 20:47:52 +03:00
|
|
|
nsGkAtoms::close, value)) {
|
2005-10-28 15:25:24 +04:00
|
|
|
value = PRUnichar(')'); // default as per the MathML REC
|
2010-11-05 13:57:51 +03:00
|
|
|
} else {
|
|
|
|
value.CompressWhitespace();
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2000-02-07 11:51:10 +03:00
|
|
|
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
1999-11-22 01:16:47 +03:00
|
|
|
mCloseChar = new nsMathMLChar;
|
2005-10-28 15:25:24 +04:00
|
|
|
mCloseChar->SetData(aPresContext, value);
|
|
|
|
isMutable = nsMathMLOperators::IsMutableOperator(value);
|
2002-02-07 07:38:08 +03:00
|
|
|
ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, mCloseChar, isMutable);
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2000-02-07 11:51:10 +03:00
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
//////////////
|
|
|
|
// see if separators are there ...
|
2010-11-05 13:57:51 +03:00
|
|
|
if (!GetAttribute(mContent, mPresentationData.mstyle,
|
|
|
|
nsGkAtoms::separators_, value)) {
|
2005-10-28 15:25:24 +04:00
|
|
|
value = PRUnichar(','); // default as per the MathML REC
|
2010-11-05 13:57:51 +03:00
|
|
|
} else {
|
2010-03-23 11:27:43 +03:00
|
|
|
value.StripWhitespace();
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2000-02-07 11:51:10 +03:00
|
|
|
|
2005-10-28 15:25:24 +04:00
|
|
|
mSeparatorsCount = value.Length();
|
1999-11-22 01:16:47 +03:00
|
|
|
if (0 < mSeparatorsCount) {
|
2002-02-19 02:16:33 +03:00
|
|
|
PRInt32 sepCount = mFrames.GetLength() - 1;
|
1999-11-22 01:16:47 +03:00
|
|
|
if (0 < sepCount) {
|
|
|
|
mSeparatorsChar = new nsMathMLChar[sepCount];
|
|
|
|
nsAutoString sepChar;
|
|
|
|
for (PRInt32 i = 0; i < sepCount; i++) {
|
2002-02-07 07:38:08 +03:00
|
|
|
if (i < mSeparatorsCount) {
|
2005-10-28 15:25:24 +04:00
|
|
|
sepChar = value[i];
|
2002-02-07 07:38:08 +03:00
|
|
|
isMutable = nsMathMLOperators::IsMutableOperator(sepChar);
|
|
|
|
}
|
|
|
|
else {
|
2005-10-28 15:25:24 +04:00
|
|
|
sepChar = value[mSeparatorsCount-1];
|
2002-02-07 07:38:08 +03:00
|
|
|
// keep the value of isMutable that was set earlier
|
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
mSeparatorsChar[i].SetData(aPresContext, sepChar);
|
2002-02-07 07:38:08 +03:00
|
|
|
ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, &mSeparatorsChar[i], isMutable);
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2007-11-07 20:16:09 +03:00
|
|
|
mSeparatorsCount = sepCount;
|
|
|
|
} else {
|
|
|
|
// No separators. Note that sepCount can be -1 here, so don't
|
|
|
|
// set mSeparatorsCount to it.
|
|
|
|
mSeparatorsCount = 0;
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-01-26 05:29:17 +03:00
|
|
|
nsMathMLmfencedFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1999-09-21 06:12:01 +04:00
|
|
|
{
|
1999-11-22 01:16:47 +03:00
|
|
|
/////////////
|
2006-01-26 05:29:17 +03:00
|
|
|
// display the content
|
|
|
|
nsresult rv = nsMathMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
////////////
|
2006-01-26 05:29:17 +03: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-22 01:16:47 +03:00
|
|
|
}
|
2006-01-26 05:29:17 +03: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-22 01:16:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
|
1999-11-22 01:16:47 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-03-28 13:38:24 +04:00
|
|
|
nsresult rv;
|
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
2007-01-23 07:06:56 +03:00
|
|
|
aDesiredSize.ascent = 0;
|
2011-04-08 05:04:40 +04:00
|
|
|
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
|
1999-11-22 01:16:47 +03:00
|
|
|
|
2002-02-27 04:35:27 +03:00
|
|
|
PRInt32 i;
|
2009-10-07 13:31:45 +04:00
|
|
|
const nsStyleFont* font = GetStyleFont();
|
2010-02-24 20:57:44 +03:00
|
|
|
aReflowState.rendContext->SetFont(font->mFont,
|
2008-12-04 19:09:53 +03:00
|
|
|
aPresContext->GetUserFontSet());
|
2011-04-08 05:05:49 +04:00
|
|
|
nsFontMetrics* fm = aReflowState.rendContext->FontMetrics();
|
2002-02-27 04:35:27 +03:00
|
|
|
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 13:38:24 +04:00
|
|
|
/////////////
|
|
|
|
// Reflow children
|
|
|
|
// Asking each child to cache its bounding metrics
|
1999-11-22 01:16:47 +03:00
|
|
|
|
2000-05-26 09:56:23 +04: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 09:47:15 +04: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 09:56:23 +04:00
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
nsReflowStatus childStatus;
|
2008-01-15 04:13:21 +03:00
|
|
|
nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
|
2009-10-07 13:31:45 +04:00
|
|
|
nsIFrame* firstChild = GetFirstChild(nsnull);
|
2002-02-15 17:39:50 +03:00
|
|
|
nsIFrame* childFrame = firstChild;
|
2007-01-23 07:06:56 +03:00
|
|
|
nscoord ascent = 0, descent = 0;
|
2009-10-07 13:31:45 +04:00
|
|
|
if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
|
2011-04-08 08:18:43 +04:00
|
|
|
// 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.
|
|
|
|
ascent = fm->MaxAscent();
|
|
|
|
descent = fm->MaxDescent();
|
2002-02-27 04:35:27 +03:00
|
|
|
}
|
1999-11-22 01:16:47 +03:00
|
|
|
while (childFrame) {
|
2007-12-03 03:54:23 +03:00
|
|
|
nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
|
|
|
|
| NS_REFLOW_CALC_BOUNDING_METRICS);
|
2001-02-23 19:10:51 +03: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 08:38:33 +03:00
|
|
|
childFrame, availSize);
|
2009-10-07 13:31:45 +04:00
|
|
|
rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
|
|
|
|
childReflowState, childStatus);
|
2001-02-23 19:10:51 +03:00
|
|
|
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
|
2007-03-02 13:55:55 +03:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Call DidReflow() for the child frames we successfully did reflow.
|
2009-10-07 13:31:45 +04:00
|
|
|
DidReflowChildren(firstChild, childFrame);
|
2007-03-02 13:55:55 +03:00
|
|
|
return rv;
|
|
|
|
}
|
2001-02-23 19:10:51 +03:00
|
|
|
|
2008-02-26 07:19:36 +03:00
|
|
|
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
|
|
|
|
childDesiredSize.mBoundingMetrics);
|
2001-02-23 19:10:51 +03:00
|
|
|
|
2007-01-23 07:06:56 +03:00
|
|
|
nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
|
|
|
|
if (descent < childDescent)
|
|
|
|
descent = childDescent;
|
|
|
|
if (ascent < childDesiredSize.ascent)
|
|
|
|
ascent = childDesiredSize.ascent;
|
2002-01-05 04:15:04 +03:00
|
|
|
|
2003-07-08 15:00:00 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
/////////////
|
|
|
|
// Ask stretchy children to stretch themselves
|
2002-01-05 04:15:04 +03:00
|
|
|
|
|
|
|
nsBoundingMetrics containerSize;
|
1999-11-22 01:16:47 +03:00
|
|
|
nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;
|
2002-01-05 04:15:04 +03:00
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
GetPreferredStretchSize(*aReflowState.rendContext,
|
|
|
|
0, /* i.e., without embellishments */
|
|
|
|
stretchDir, containerSize);
|
|
|
|
childFrame = firstChild;
|
|
|
|
while (childFrame) {
|
|
|
|
nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
|
|
|
|
if (mathmlChild) {
|
|
|
|
nsHTMLReflowMetrics childDesiredSize;
|
|
|
|
// retrieve the metrics that was stored at the previous pass
|
|
|
|
GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
|
|
|
|
childDesiredSize.mBoundingMetrics);
|
|
|
|
|
|
|
|
mathmlChild->Stretch(*aReflowState.rendContext,
|
|
|
|
stretchDir, containerSize, childDesiredSize);
|
|
|
|
// store the updated metrics
|
|
|
|
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
|
|
|
|
childDesiredSize.mBoundingMetrics);
|
|
|
|
|
|
|
|
nscoord childDescent = childDesiredSize.height - childDesiredSize.ascent;
|
|
|
|
if (descent < childDescent)
|
|
|
|
descent = childDescent;
|
|
|
|
if (ascent < childDesiredSize.ascent)
|
|
|
|
ascent = childDesiredSize.ascent;
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2009-10-07 13:31:45 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
// bug 121748: for surrounding fences & separators, use a size that covers everything
|
|
|
|
GetPreferredStretchSize(*aReflowState.rendContext,
|
|
|
|
STRETCH_CONSIDER_EMBELLISHMENTS,
|
|
|
|
stretchDir, containerSize);
|
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
//////////////////////////////////////////
|
|
|
|
// Prepare the opening fence, separators, and closing fence, and
|
2000-03-28 13:38:24 +04:00
|
|
|
// adjust the origin of children.
|
1999-11-22 01:16:47 +03:00
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
// we need to center around the axis
|
2011-07-11 08:11:28 +04:00
|
|
|
nscoord delta = NS_MAX(containerSize.ascent - axisHeight,
|
|
|
|
containerSize.descent + axisHeight);
|
|
|
|
containerSize.ascent = delta + axisHeight;
|
|
|
|
containerSize.descent = delta - axisHeight;
|
1999-11-22 01:16:47 +03:00
|
|
|
|
|
|
|
/////////////////
|
|
|
|
// opening fence ...
|
2009-10-07 13:31:45 +04:00
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, mOpenChar,
|
2008-01-09 12:38:28 +03:00
|
|
|
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel,
|
2007-01-23 07:06:56 +03:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent);
|
1999-11-22 01:16:47 +03:00
|
|
|
/////////////////
|
|
|
|
// separators ...
|
2009-10-07 13:31:45 +04:00
|
|
|
for (i = 0; i < mSeparatorsCount; i++) {
|
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, &mSeparatorsChar[i],
|
2008-01-09 12:38:28 +03:00
|
|
|
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
|
2007-01-23 07:06:56 +03:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent);
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
|
|
|
/////////////////
|
|
|
|
// closing fence ...
|
2009-10-07 13:31:45 +04:00
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, mCloseChar,
|
2008-01-09 12:38:28 +03:00
|
|
|
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
|
2007-01-23 07:06:56 +03:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent);
|
1999-11-22 01:16:47 +03:00
|
|
|
|
|
|
|
//////////////////
|
2000-03-28 13:38:24 +04:00
|
|
|
// Adjust the origins of each child.
|
|
|
|
// and update our bounding metrics
|
|
|
|
|
|
|
|
i = 0;
|
2000-05-26 09:56:23 +04:00
|
|
|
nscoord dx = 0;
|
2000-03-28 13:38:24 +04:00
|
|
|
nsBoundingMetrics bm;
|
|
|
|
PRBool firstTime = PR_TRUE;
|
2009-10-07 13:31:45 +04:00
|
|
|
if (mOpenChar) {
|
|
|
|
PlaceChar(mOpenChar, ascent, bm, dx);
|
2002-01-05 04:15:04 +03:00
|
|
|
aDesiredSize.mBoundingMetrics = bm;
|
2000-03-28 13:38:24 +04:00
|
|
|
firstTime = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-02-15 17:39:50 +03:00
|
|
|
childFrame = firstChild;
|
1999-11-22 01:16:47 +03: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 08:38:33 +03:00
|
|
|
nsHTMLReflowMetrics childSize;
|
2001-02-23 19:10:51 +03:00
|
|
|
GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);
|
|
|
|
if (firstTime) {
|
|
|
|
firstTime = PR_FALSE;
|
2002-01-05 04:15:04 +03:00
|
|
|
aDesiredSize.mBoundingMetrics = bm;
|
2001-02-23 19:10:51 +03:00
|
|
|
}
|
|
|
|
else
|
2002-01-05 04:15:04 +03:00
|
|
|
aDesiredSize.mBoundingMetrics += bm;
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
FinishReflowChild(childFrame, aPresContext, nsnull, childSize,
|
|
|
|
dx, ascent - childSize.ascent, 0);
|
2001-02-23 19:10:51 +03:00
|
|
|
dx += childSize.width;
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
if (i < mSeparatorsCount) {
|
|
|
|
PlaceChar(&mSeparatorsChar[i], ascent, bm, dx);
|
2002-01-05 04:15:04 +03:00
|
|
|
aDesiredSize.mBoundingMetrics += bm;
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2001-02-23 19:10:51 +03:00
|
|
|
i++;
|
|
|
|
|
2003-07-08 15:00:00 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
if (mCloseChar) {
|
|
|
|
PlaceChar(mCloseChar, ascent, bm, dx);
|
2000-03-28 13:38:24 +04:00
|
|
|
if (firstTime)
|
2002-01-05 04:15:04 +03:00
|
|
|
aDesiredSize.mBoundingMetrics = bm;
|
2000-03-28 13:38:24 +04:00
|
|
|
else
|
2002-01-05 04:15:04 +03:00
|
|
|
aDesiredSize.mBoundingMetrics += bm;
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
|
|
|
|
2002-01-05 04:15:04 +03:00
|
|
|
aDesiredSize.width = aDesiredSize.mBoundingMetrics.width;
|
2007-01-23 07:06:56 +03:00
|
|
|
aDesiredSize.height = ascent + descent;
|
|
|
|
aDesiredSize.ascent = ascent;
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
SetBoundingMetrics(aDesiredSize.mBoundingMetrics);
|
|
|
|
SetReference(nsPoint(0, aDesiredSize.ascent));
|
2002-01-05 04:15:04 +03:00
|
|
|
|
2005-09-16 04:39:27 +04:00
|
|
|
// see if we should fix the spacing
|
2009-10-07 13:31:45 +04:00
|
|
|
FixInterFrameSpacing(aDesiredSize);
|
2008-02-26 07:19:36 +03:00
|
|
|
|
|
|
|
// Finished with these:
|
2009-10-07 13:31:45 +04:00
|
|
|
ClearSavedChildMetrics();
|
2005-09-16 04:39:27 +04:00
|
|
|
|
2007-12-29 02:04:19 +03:00
|
|
|
// Set our overflow area
|
2009-10-07 13:31:45 +04:00
|
|
|
GatherAndStoreOverflow(&aDesiredSize);
|
2007-12-29 02:04:19 +03:00
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1999-11-22 01:16:47 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-03-14 08:02:49 +03: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 09:56:23 +04:00
|
|
|
// helper functions to perform the common task of formatting our chars
|
2002-01-05 04:15:04 +03:00
|
|
|
/*static*/ nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmfencedFrame::ReflowChar(nsPresContext* aPresContext,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext& aRenderingContext,
|
1999-11-22 01:16:47 +03:00
|
|
|
nsMathMLChar* aMathMLChar,
|
|
|
|
nsOperatorFlags aForm,
|
|
|
|
PRInt32 aScriptLevel,
|
2000-03-28 13:38:24 +04:00
|
|
|
nscoord axisHeight,
|
2002-02-27 04:35:27 +03:00
|
|
|
nscoord leading,
|
1999-11-22 01:16:47 +03:00
|
|
|
nscoord em,
|
2000-03-28 13:38:24 +04:00
|
|
|
nsBoundingMetrics& aContainerSize,
|
2007-01-23 07:06:56 +03:00
|
|
|
nscoord& aAscent,
|
|
|
|
nscoord& aDescent)
|
1999-11-22 01:16:47 +03:00
|
|
|
{
|
|
|
|
if (aMathMLChar && 0 < aMathMLChar->Length()) {
|
2008-03-14 08:02:49 +03:00
|
|
|
nscoord leftSpace;
|
|
|
|
nscoord rightSpace;
|
|
|
|
GetCharSpacing(aMathMLChar, aForm, aScriptLevel, em, leftSpace, rightSpace);
|
2000-07-10 17:57:52 +04:00
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
// stretch the char to the appropriate height if it is not big enough.
|
|
|
|
nsBoundingMetrics charSize;
|
2000-07-25 04:08:15 +04:00
|
|
|
nsresult res = aMathMLChar->Stretch(aPresContext, aRenderingContext,
|
|
|
|
NS_STRETCH_DIRECTION_VERTICAL,
|
|
|
|
aContainerSize, charSize);
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2002-02-27 04:35:27 +03:00
|
|
|
if (NS_STRETCH_DIRECTION_UNSUPPORTED != aMathMLChar->GetStretchDirection()) {
|
2000-03-28 13:38:24 +04: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 04:15:04 +03:00
|
|
|
// either it hasn't changed or stretching the char failed (i.e.,
|
|
|
|
// GetBoundingMetrics failed)
|
2002-02-27 04:35:27 +03:00
|
|
|
leading = 0;
|
2002-01-05 04:15:04 +03:00
|
|
|
if (NS_FAILED(res)) {
|
2008-03-14 08:02:49 +03:00
|
|
|
nsAutoString data;
|
|
|
|
aMathMLChar->GetData(data);
|
2011-04-08 05:04:40 +04:00
|
|
|
nsBoundingMetrics metrics =
|
|
|
|
aRenderingContext.GetBoundingMetrics(data.get(), data.Length());
|
2011-04-08 05:04:40 +04:00
|
|
|
charSize.ascent = metrics.ascent;
|
|
|
|
charSize.descent = metrics.descent;
|
|
|
|
charSize.width = metrics.width;
|
2002-01-05 04:15:04 +03:00
|
|
|
// Set this as the bounding metrics of the MathMLChar to leave
|
|
|
|
// the necessary room to paint the char.
|
|
|
|
aMathMLChar->SetBoundingMetrics(charSize);
|
2000-07-25 04:08:15 +04:00
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
|
2007-01-23 07:06:56 +03:00
|
|
|
if (aAscent < charSize.ascent + leading)
|
|
|
|
aAscent = charSize.ascent + leading;
|
|
|
|
if (aDescent < charSize.descent + leading)
|
|
|
|
aDescent = charSize.descent + leading;
|
2000-03-28 13:38:24 +04:00
|
|
|
|
1999-11-22 01:16:47 +03:00
|
|
|
// account the spacing
|
2008-03-14 08:02:49 +03:00
|
|
|
charSize.width += leftSpace + rightSpace;
|
1999-11-22 01:16:47 +03:00
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
// x-origin is used to store lspace ...
|
|
|
|
// y-origin is used to stored the ascent ...
|
2008-03-14 08:02:49 +03:00
|
|
|
aMathMLChar->SetRect(nsRect(leftSpace,
|
2000-03-28 13:38:24 +04:00
|
|
|
charSize.ascent, charSize.width,
|
|
|
|
charSize.ascent + charSize.descent));
|
1999-11-22 01:16:47 +03:00
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-22 01:16:47 +03:00
|
|
|
|
2002-01-05 04:15:04 +03:00
|
|
|
/*static*/ void
|
2000-05-26 09:56:23 +04: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 04:08:15 +04:00
|
|
|
// the char's y-origin was used to store the ascent ...
|
2008-03-14 08:02:49 +03:00
|
|
|
// the char's width was used to store the advance with (with spacing) ...
|
2000-05-26 09:56:23 +04:00
|
|
|
nsRect rect;
|
|
|
|
aMathMLChar->GetRect(rect);
|
2002-02-27 04:35:27 +03:00
|
|
|
|
2000-05-26 09:56:23 +04:00
|
|
|
nscoord dy = aDesiredAscent - rect.y;
|
2002-02-27 04:35:27 +03:00
|
|
|
if (aMathMLChar->GetStretchDirection() != NS_STRETCH_DIRECTION_UNSUPPORTED) {
|
2000-05-26 09:56:23 +04: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 04:35:27 +03:00
|
|
|
aMathMLChar->SetRect(nsRect(dx + rect.x, dy, bm.width, rect.height));
|
2000-05-26 09:56:23 +04:00
|
|
|
|
|
|
|
bm.leftBearing += rect.x;
|
|
|
|
bm.rightBearing += rect.x;
|
2002-02-27 04:35:27 +03:00
|
|
|
|
2000-05-26 09:56:23 +04:00
|
|
|
// return rect.width since it includes lspace and rspace
|
|
|
|
bm.width = rect.width;
|
|
|
|
dx += rect.width;
|
|
|
|
}
|
|
|
|
|
2008-03-14 08:02:49 +03:00
|
|
|
static nscoord
|
|
|
|
GetMaxCharWidth(nsPresContext* aPresContext,
|
2011-04-08 05:04:40 +04:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2008-03-14 08:02:49 +03:00
|
|
|
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
|
2011-04-08 05:04:40 +04:00
|
|
|
nsMathMLmfencedFrame::GetIntrinsicWidth(nsRenderingContext* aRenderingContext)
|
2008-03-14 08:02:49 +03:00
|
|
|
{
|
|
|
|
nscoord width = 0;
|
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
const nsStyleFont* font = GetStyleFont();
|
2011-04-08 05:05:49 +04:00
|
|
|
nsRefPtr<nsFontMetrics> fm = presContext->GetMetricsFor(font->mFont);
|
2008-03-14 08:02:49 +03:00
|
|
|
nscoord em;
|
|
|
|
GetEmHeight(fm, em);
|
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
if (mOpenChar) {
|
2008-03-14 08:02:49 +03:00
|
|
|
width +=
|
2009-10-07 13:31:45 +04:00
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, mOpenChar,
|
2008-03-14 08:02:49 +03:00
|
|
|
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRInt32 i = 0;
|
2009-10-07 13:31:45 +04:00
|
|
|
nsIFrame* childFrame = GetFirstChild(nsnull);
|
2008-03-14 08:02:49 +03:00
|
|
|
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);
|
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
if (i < mSeparatorsCount) {
|
2008-03-14 08:02:49 +03:00
|
|
|
width +=
|
2009-10-07 13:31:45 +04:00
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, &mSeparatorsChar[i],
|
2008-03-14 08:02:49 +03:00
|
|
|
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
2009-10-07 13:31:45 +04:00
|
|
|
if (mCloseChar) {
|
2008-03-14 08:02:49 +03:00
|
|
|
width +=
|
2009-10-07 13:31:45 +04:00
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, mCloseChar,
|
2008-03-14 08:02:49 +03:00
|
|
|
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
2005-09-16 04:39:27 +04: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 13:38:24 +04:00
|
|
|
// ----------------------
|
|
|
|
// the Style System will use these to pass the proper style context to our MathMLChar
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext*
|
|
|
|
nsMathMLmfencedFrame::GetAdditionalStyleContext(PRInt32 aIndex) const
|
2000-03-28 13:38:24 +04: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 03:32:13 +03:00
|
|
|
return nsnull;
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aIndex < mSeparatorsCount) {
|
2003-02-22 03:32:13 +03:00
|
|
|
return mSeparatorsChar[aIndex].GetStyleContext();
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
else if (aIndex == openIndex) {
|
2003-02-22 03:32:13 +03:00
|
|
|
return mOpenChar->GetStyleContext();
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
else if (aIndex == closeIndex) {
|
2003-02-22 03:32:13 +03:00
|
|
|
return mCloseChar->GetStyleContext();
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
2003-02-22 03:32:13 +03:00
|
|
|
return nsnull;
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
void
|
2000-03-28 13:38:24 +04:00
|
|
|
nsMathMLmfencedFrame::SetAdditionalStyleContext(PRInt32 aIndex,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext)
|
2000-03-28 13:38:24 +04: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 03:32:13 +03:00
|
|
|
return;
|
2000-03-28 13:38:24 +04: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 06:12:01 +04:00
|
|
|
}
|