2007-06-12 06:10:23 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-09-21 02:12:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "nsMathMLmfencedFrame.h"
|
2013-08-30 21:37:12 +00:00
|
|
|
#include "nsRenderingContext.h"
|
|
|
|
#include "nsMathMLChar.h"
|
2013-01-15 12:22:03 +00:00
|
|
|
#include <algorithm>
|
1999-09-21 02:12:01 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// <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
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmfencedFrame)
|
|
|
|
|
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
|
|
|
|
2011-05-12 21:31:48 +00:00
|
|
|
RemoveFencesAndSeparators();
|
|
|
|
CreateFencesAndSeparators(PresContext());
|
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
return NS_OK;
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsMathMLmfencedFrame::SetInitialChildList(ChildListID aListID,
|
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
|
2011-08-24 20:54:30 +00:00
|
|
|
nsresult rv = nsMathMLContainerFrame::SetInitialChildList(aListID, aChildList);
|
1999-11-21 22:16:47 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-09-21 02:12:01 +00:00
|
|
|
|
2011-05-18 23:56:14 +00: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-16 21:53:42 +00:00
|
|
|
// No need to track the style contexts given to our MathML chars.
|
2002-02-07 04:38:08 +00:00
|
|
|
// The Style System will use Get/SetAdditionalStyleContext() to keep them
|
|
|
|
// up-to-date if dynamic changes arise.
|
2010-11-05 10:57:39 +00:00
|
|
|
CreateFencesAndSeparators(PresContext());
|
|
|
|
return NS_OK;
|
2002-02-07 04:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 15:56:38 +00:00
|
|
|
nsMathMLmfencedFrame::AttributeChanged(int32_t aNameSpaceID,
|
2002-02-07 04:38:08 +00:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t 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
|
2012-08-22 15:56:38 +00:00
|
|
|
nsMathMLmfencedFrame::ChildListChanged(int32_t 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()
|
|
|
|
{
|
2011-05-17 14:01:36 +00:00
|
|
|
delete mOpenChar;
|
|
|
|
delete mCloseChar;
|
1999-11-21 22:16:47 +00:00
|
|
|
if (mSeparatorsChar) delete[] mSeparatorsChar;
|
2002-02-07 04:38:08 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
mOpenChar = nullptr;
|
|
|
|
mCloseChar = nullptr;
|
|
|
|
mSeparatorsChar = nullptr;
|
1999-11-21 22:16:47 +00:00
|
|
|
mSeparatorsCount = 0;
|
|
|
|
}
|
|
|
|
|
2010-11-05 10:57:39 +00:00
|
|
|
void
|
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;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isMutable = 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)) {
|
2014-01-04 15:02:17 +00:00
|
|
|
value = char16_t('('); // default as per the MathML REC
|
2010-11-05 10:57:51 +00:00
|
|
|
} else {
|
|
|
|
value.CompressWhitespace();
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
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;
|
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)) {
|
2014-01-04 15:02:17 +00:00
|
|
|
value = char16_t(')'); // default as per the MathML REC
|
2010-11-05 10:57:51 +00:00
|
|
|
} else {
|
|
|
|
value.CompressWhitespace();
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
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;
|
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 ...
|
2010-11-05 10:57:51 +00:00
|
|
|
if (!GetAttribute(mContent, mPresentationData.mstyle,
|
|
|
|
nsGkAtoms::separators_, value)) {
|
2014-01-04 15:02:17 +00:00
|
|
|
value = char16_t(','); // default as per the MathML REC
|
2010-11-05 10:57:51 +00:00
|
|
|
} else {
|
2010-03-23 08:27:43 +00:00
|
|
|
value.StripWhitespace();
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
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) {
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t sepCount = mFrames.GetLength() - 1;
|
1999-11-21 22:16:47 +00:00
|
|
|
if (0 < sepCount) {
|
|
|
|
mSeparatorsChar = new nsMathMLChar[sepCount];
|
|
|
|
nsAutoString sepChar;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
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
|
2013-02-14 11:12:27 +00:00
|
|
|
nsMathMLContainerFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2006-01-26 02:29:17 +00:00
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
////////////
|
2006-01-26 02:29:17 +00:00
|
|
|
// display fences and separators
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count = 0;
|
2006-01-26 02:29:17 +00:00
|
|
|
if (mOpenChar) {
|
2013-02-14 11:12:27 +00:00
|
|
|
mOpenChar->Display(aBuilder, this, aLists, count++);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mCloseChar) {
|
2013-02-14 11:12:27 +00:00
|
|
|
mCloseChar->Display(aBuilder, this, aLists, count++);
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; i < mSeparatorsCount; i++) {
|
2013-02-14 11:12:27 +00:00
|
|
|
mSeparatorsChar[i].Display(aBuilder, this, aLists, count++);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
2000-03-28 09:38:24 +00:00
|
|
|
nsresult rv;
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Width() = aDesiredSize.Height() = 0;
|
|
|
|
aDesiredSize.SetTopAscent(0);
|
2011-04-08 01:04:40 +00:00
|
|
|
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
|
1999-11-21 22:16:47 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i;
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleFont* font = StyleFont();
|
2011-08-14 17:08:04 +00:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
|
|
|
aReflowState.rendContext->SetFont(fm);
|
2002-02-27 01:35:27 +00: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 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);
|
2011-08-24 20:54:30 +00:00
|
|
|
nsIFrame* firstChild = GetFirstPrincipalChild();
|
2002-02-15 14:39:50 +00:00
|
|
|
nsIFrame* childFrame = firstChild;
|
2007-01-23 04:06:56 +00:00
|
|
|
nscoord ascent = 0, descent = 0;
|
2009-10-07 09:31:45 +00:00
|
|
|
if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
|
2011-04-08 04:18:43 +00: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 01:35:27 +00:00
|
|
|
}
|
1999-11-21 22:16:47 +00:00
|
|
|
while (childFrame) {
|
2013-12-29 22:48:13 +00:00
|
|
|
nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(),
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.mFlags
|
2007-12-03 00:54:23 +00:00
|
|
|
| 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);
|
2009-10-07 09:31:45 +00:00
|
|
|
rv = 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.
|
2009-10-07 09:31:45 +00:00
|
|
|
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
|
|
|
|
2013-12-27 17:59:52 +00:00
|
|
|
nscoord childDescent = childDesiredSize.Height() - childDesiredSize.TopAscent();
|
2007-01-23 04:06:56 +00:00
|
|
|
if (descent < childDescent)
|
|
|
|
descent = childDescent;
|
2013-12-27 17:59:52 +00:00
|
|
|
if (ascent < childDesiredSize.TopAscent())
|
|
|
|
ascent = childDesiredSize.TopAscent();
|
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
|
|
|
|
2009-10-07 09:31:45 +00:00
|
|
|
GetPreferredStretchSize(*aReflowState.rendContext,
|
|
|
|
0, /* i.e., without embellishments */
|
|
|
|
stretchDir, containerSize);
|
|
|
|
childFrame = firstChild;
|
|
|
|
while (childFrame) {
|
|
|
|
nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
|
|
|
|
if (mathmlChild) {
|
2013-12-29 22:48:13 +00:00
|
|
|
nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode());
|
2009-10-07 09:31:45 +00:00
|
|
|
// 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);
|
|
|
|
|
2013-12-27 17:59:52 +00:00
|
|
|
nscoord childDescent = childDesiredSize.Height() - childDesiredSize.TopAscent();
|
2009-10-07 09:31:45 +00:00
|
|
|
if (descent < childDescent)
|
|
|
|
descent = childDescent;
|
2013-12-27 17:59:52 +00:00
|
|
|
if (ascent < childDesiredSize.TopAscent())
|
|
|
|
ascent = childDesiredSize.TopAscent();
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2009-10-07 09:31:45 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
|
2009-10-07 09:31:45 +00:00
|
|
|
// bug 121748: for surrounding fences & separators, use a size that covers everything
|
|
|
|
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
|
2013-01-15 12:22:03 +00:00
|
|
|
nscoord delta = std::max(containerSize.ascent - axisHeight,
|
2011-07-11 04:11:28 +00:00
|
|
|
containerSize.descent + axisHeight);
|
|
|
|
containerSize.ascent = delta + axisHeight;
|
|
|
|
containerSize.descent = delta - axisHeight;
|
1999-11-21 22:16:47 +00:00
|
|
|
|
2013-05-29 23:26:40 +00:00
|
|
|
bool isRTL = StyleVisibility()->mDirection;
|
2011-12-21 22:22:00 +00:00
|
|
|
|
1999-11-21 22:16:47 +00:00
|
|
|
/////////////////
|
|
|
|
// opening fence ...
|
2009-10-07 09:31:45 +00:00
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, mOpenChar,
|
2008-01-09 09:38:28 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel,
|
2011-12-21 22:22:00 +00:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
|
1999-11-21 22:16:47 +00:00
|
|
|
/////////////////
|
|
|
|
// separators ...
|
2009-10-07 09:31:45 +00:00
|
|
|
for (i = 0; i < mSeparatorsCount; i++) {
|
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, &mSeparatorsChar[i],
|
2008-01-09 09:38:28 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel,
|
2011-12-21 22:22:00 +00:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
|
|
|
/////////////////
|
|
|
|
// closing fence ...
|
2009-10-07 09:31:45 +00:00
|
|
|
ReflowChar(aPresContext, *aReflowState.rendContext, mCloseChar,
|
2008-01-09 09:38:28 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel,
|
2011-12-21 22:22:00 +00:00
|
|
|
axisHeight, leading, em, containerSize, ascent, descent, isRTL);
|
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;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool firstTime = true;
|
2010-01-05 10:22:31 +00:00
|
|
|
nsMathMLChar *leftChar, *rightChar;
|
|
|
|
if (isRTL) {
|
|
|
|
leftChar = mCloseChar;
|
|
|
|
rightChar = mOpenChar;
|
|
|
|
} else {
|
|
|
|
leftChar = mOpenChar;
|
|
|
|
rightChar = mCloseChar;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (leftChar) {
|
|
|
|
PlaceChar(leftChar, ascent, bm, dx);
|
2002-01-05 01:15:04 +00:00
|
|
|
aDesiredSize.mBoundingMetrics = bm;
|
2011-10-17 14:59:28 +00:00
|
|
|
firstTime = false;
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
|
|
|
|
2010-01-05 10:22:31 +00:00
|
|
|
if (isRTL) {
|
|
|
|
childFrame = this->GetLastChild(nsIFrame::kPrincipalList);
|
|
|
|
} else {
|
|
|
|
childFrame = firstChild;
|
|
|
|
}
|
1999-11-21 22:16:47 +00:00
|
|
|
while (childFrame) {
|
2013-12-29 22:48:13 +00:00
|
|
|
nsHTMLReflowMetrics childSize(aReflowState.GetWritingMode());
|
2001-02-23 16:10:51 +00:00
|
|
|
GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);
|
|
|
|
if (firstTime) {
|
2011-10-17 14:59:28 +00:00
|
|
|
firstTime = 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
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
FinishReflowChild(childFrame, aPresContext, nullptr, childSize,
|
2013-12-27 17:59:52 +00:00
|
|
|
dx, ascent - childSize.TopAscent(), 0);
|
|
|
|
dx += childSize.Width();
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2009-10-07 09:31:45 +00:00
|
|
|
if (i < mSeparatorsCount) {
|
2010-01-05 10:22:31 +00:00
|
|
|
PlaceChar(&mSeparatorsChar[isRTL ? mSeparatorsCount - 1 - i : 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++;
|
|
|
|
|
2010-01-05 10:22:31 +00:00
|
|
|
if (isRTL) {
|
|
|
|
childFrame = childFrame->GetPrevSibling();
|
|
|
|
} else {
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
|
|
}
|
1999-11-21 22:16:47 +00:00
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2010-01-05 10:22:31 +00:00
|
|
|
if (rightChar) {
|
|
|
|
PlaceChar(rightChar, 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
|
|
|
}
|
|
|
|
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Width() = aDesiredSize.mBoundingMetrics.width;
|
|
|
|
aDesiredSize.Height() = ascent + descent;
|
|
|
|
aDesiredSize.SetTopAscent(ascent);
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2009-10-07 09:31:45 +00:00
|
|
|
SetBoundingMetrics(aDesiredSize.mBoundingMetrics);
|
2013-12-27 17:59:52 +00:00
|
|
|
SetReference(nsPoint(0, aDesiredSize.TopAscent()));
|
2002-01-05 01:15:04 +00:00
|
|
|
|
2005-09-16 00:39:27 +00:00
|
|
|
// see if we should fix the spacing
|
2009-10-07 09:31:45 +00:00
|
|
|
FixInterFrameSpacing(aDesiredSize);
|
2008-02-26 04:19:36 +00:00
|
|
|
|
|
|
|
// Finished with these:
|
2009-10-07 09:31:45 +00:00
|
|
|
ClearSavedChildMetrics();
|
2005-09-16 00:39:27 +00:00
|
|
|
|
2007-12-28 23:04:19 +00:00
|
|
|
// Set our overflow area
|
2009-10-07 09:31:45 +00:00
|
|
|
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,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aScriptLevel,
|
2008-03-14 05:02:49 +00:00
|
|
|
nscoord em,
|
|
|
|
nscoord& aLeftSpace,
|
|
|
|
nscoord& aRightSpace)
|
|
|
|
{
|
|
|
|
nsAutoString data;
|
|
|
|
aMathMLChar->GetData(data);
|
|
|
|
nsOperatorFlags flags = 0;
|
|
|
|
float lspace = 0.0f;
|
|
|
|
float rspace = 0.0f;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool found = nsMathMLOperators::LookupOperator(data, aForm,
|
2008-03-14 05:02:49 +00:00
|
|
|
&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,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext& aRenderingContext,
|
1999-11-21 22:16:47 +00:00
|
|
|
nsMathMLChar* aMathMLChar,
|
|
|
|
nsOperatorFlags aForm,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t 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,
|
2011-12-21 22:22:00 +00:00
|
|
|
nscoord& aDescent,
|
|
|
|
bool aRTL)
|
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,
|
2011-12-21 22:22:00 +00:00
|
|
|
aContainerSize, charSize,
|
|
|
|
NS_STRETCH_NORMAL, aRTL);
|
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);
|
2011-04-08 01:04:40 +00:00
|
|
|
nsBoundingMetrics metrics =
|
|
|
|
aRenderingContext.GetBoundingMetrics(data.get(), data.Length());
|
2011-04-08 01:04:40 +00:00
|
|
|
charSize.ascent = metrics.ascent;
|
|
|
|
charSize.descent = metrics.descent;
|
|
|
|
charSize.width = metrics.width;
|
2002-01-05 01:15:04 +00: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 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,
|
2011-04-08 01:04:40 +00:00
|
|
|
nsRenderingContext* aRenderingContext,
|
2008-03-14 05:02:49 +00:00
|
|
|
nsMathMLChar* aMathMLChar,
|
|
|
|
nsOperatorFlags aForm,
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t aScriptLevel,
|
2008-03-14 05:02:49 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-11-25 14:20:20 +00:00
|
|
|
/* virtual */ void
|
|
|
|
nsMathMLmfencedFrame::GetIntrinsicWidthMetrics(nsRenderingContext* aRenderingContext, nsHTMLReflowMetrics& aDesiredSize)
|
2008-03-14 05:02:49 +00:00
|
|
|
{
|
|
|
|
nscoord width = 0;
|
|
|
|
|
2009-10-07 09:31:45 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleFont* font = StyleFont();
|
2011-08-14 17:08:04 +00:00
|
|
|
nsRefPtr<nsFontMetrics> fm;
|
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
|
2008-03-14 05:02:49 +00:00
|
|
|
nscoord em;
|
|
|
|
GetEmHeight(fm, em);
|
|
|
|
|
2009-10-07 09:31:45 +00:00
|
|
|
if (mOpenChar) {
|
2008-03-14 05:02:49 +00:00
|
|
|
width +=
|
2009-10-07 09:31:45 +00:00
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, mOpenChar,
|
2008-03-14 05:02:49 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_PREFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i = 0;
|
2011-08-24 20:54:30 +00:00
|
|
|
nsIFrame* childFrame = GetFirstPrincipalChild();
|
2008-03-14 05:02:49 +00: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 09:31:45 +00:00
|
|
|
if (i < mSeparatorsCount) {
|
2008-03-14 05:02:49 +00:00
|
|
|
width +=
|
2009-10-07 09:31:45 +00:00
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, &mSeparatorsChar[i],
|
2008-03-14 05:02:49 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_INFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
|
|
|
|
childFrame = childFrame->GetNextSibling();
|
|
|
|
}
|
|
|
|
|
2009-10-07 09:31:45 +00:00
|
|
|
if (mCloseChar) {
|
2008-03-14 05:02:49 +00:00
|
|
|
width +=
|
2009-10-07 09:31:45 +00:00
|
|
|
GetMaxCharWidth(presContext, aRenderingContext, mCloseChar,
|
2008-03-14 05:02:49 +00:00
|
|
|
NS_MATHML_OPERATOR_FORM_POSTFIX, font->mScriptLevel, em);
|
|
|
|
}
|
|
|
|
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Width() = width;
|
2013-11-25 14:20:20 +00:00
|
|
|
aDesiredSize.mBoundingMetrics.width = width;
|
|
|
|
aDesiredSize.mBoundingMetrics.leftBearing = 0;
|
|
|
|
aDesiredSize.mBoundingMetrics.rightBearing = width;
|
2008-03-14 05:02:49 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t i = 0; i < mSeparatorsCount; i++) {
|
2005-09-16 00:39:27 +00:00
|
|
|
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*
|
2012-08-22 15:56:38 +00:00
|
|
|
nsMathMLmfencedFrame::GetAdditionalStyleContext(int32_t aIndex) const
|
2000-03-28 09:38:24 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t openIndex = -1;
|
|
|
|
int32_t closeIndex = -1;
|
|
|
|
int32_t lastIndex = mSeparatorsCount-1;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
|
|
|
if (mOpenChar) {
|
|
|
|
lastIndex++;
|
|
|
|
openIndex = lastIndex;
|
|
|
|
}
|
|
|
|
if (mCloseChar) {
|
|
|
|
lastIndex++;
|
|
|
|
closeIndex = lastIndex;
|
|
|
|
}
|
|
|
|
if (aIndex < 0 || aIndex > lastIndex) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
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
|
|
|
}
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
|
|
|
|
2003-02-22 00:32:13 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsMathMLmfencedFrame::SetAdditionalStyleContext(int32_t aIndex,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aStyleContext)
|
2000-03-28 09:38:24 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t openIndex = -1;
|
|
|
|
int32_t closeIndex = -1;
|
|
|
|
int32_t lastIndex = mSeparatorsCount-1;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|