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-03-28 09:38:24 +00:00
|
|
|
* Shyjan Mahamud <mahamud@cs.cmu.edu>
|
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"
|
1999-09-21 02:12:01 +00:00
|
|
|
#include "nsUnitConversion.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1999-09-21 02:12:01 +00:00
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsIFontMetrics.h"
|
|
|
|
|
|
|
|
#include "nsMathMLmoverFrame.h"
|
2001-02-02 09:37:14 +00:00
|
|
|
#include "nsMathMLmsupFrame.h"
|
1999-09-21 02:12:01 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// <mover> -- attach an overscript to a base - implementation
|
|
|
|
//
|
|
|
|
|
2005-11-11 02:36:29 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewMathMLmoverFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1999-09-21 02:12:01 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsMathMLmoverFrame(aContext);
|
1999-09-21 02:12:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsMathMLmoverFrame::~nsMathMLmoverFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
NS_IMETHODIMP
|
2005-09-07 16:49:21 +00:00
|
|
|
nsMathMLmoverFrame::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
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
if (nsGkAtoms::accent_ == aAttribute) {
|
2002-02-07 04:38:08 +00:00
|
|
|
// When we have automatic data to update within ourselves, we ask our
|
|
|
|
// parent to re-layout its children
|
2005-02-07 01:57:50 +00:00
|
|
|
return ReLayoutChildren(mParent);
|
2002-02-07 04:38:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsMathMLContainerFrame::
|
2005-09-07 16:49:21 +00:00
|
|
|
AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2002-02-07 04:38:08 +00:00
|
|
|
}
|
|
|
|
|
2002-01-09 18:51:30 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:57:50 +00:00
|
|
|
nsMathMLmoverFrame::UpdatePresentationData(PRInt32 aScriptLevelIncrement,
|
2002-01-09 18:51:30 +00:00
|
|
|
PRUint32 aFlagsValues,
|
|
|
|
PRUint32 aFlagsToUpdate)
|
|
|
|
{
|
2005-02-07 01:57:50 +00:00
|
|
|
nsMathMLContainerFrame::UpdatePresentationData(
|
2002-01-09 18:51:30 +00:00
|
|
|
aScriptLevelIncrement, aFlagsValues, aFlagsToUpdate);
|
|
|
|
// disable the stretch-all flag if we are going to act like a superscript
|
2002-02-07 04:38:08 +00:00
|
|
|
if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
|
2002-01-09 18:51:30 +00:00
|
|
|
!NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
|
2002-02-07 04:38:08 +00:00
|
|
|
mPresentationData.flags &= ~NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY;
|
2002-01-09 18:51:30 +00:00
|
|
|
}
|
|
|
|
else {
|
2002-02-07 04:38:08 +00:00
|
|
|
mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY;
|
2002-01-09 18:51:30 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-10 04:42:55 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:57:50 +00:00
|
|
|
nsMathMLmoverFrame::UpdatePresentationDataFromChildAt(PRInt32 aFirstIndex,
|
2002-01-10 04:42:55 +00:00
|
|
|
PRInt32 aLastIndex,
|
|
|
|
PRInt32 aScriptLevelIncrement,
|
|
|
|
PRUint32 aFlagsValues,
|
|
|
|
PRUint32 aFlagsToUpdate)
|
|
|
|
{
|
|
|
|
// mover is special... The REC says:
|
|
|
|
// Within overscript, <mover> always sets displaystyle to "false",
|
|
|
|
// but increments scriptlevel by 1 only when accent is "false".
|
|
|
|
// This means that
|
|
|
|
// 1. don't allow displaystyle to change in the overscript
|
|
|
|
// 2. if the value of the accent is changed, we need to recompute the
|
|
|
|
// scriptlevel of the overscript. The problem is that the accent
|
|
|
|
// can change in the <mo> deep down the embellished hierarchy
|
|
|
|
|
|
|
|
// Do #1 here, never allow displaystyle to be changed in the overscript
|
|
|
|
PRInt32 index = 0;
|
|
|
|
nsIFrame* childFrame = mFrames.FirstChild();
|
|
|
|
while (childFrame) {
|
|
|
|
if ((index >= aFirstIndex) &&
|
|
|
|
((aLastIndex <= 0) || ((aLastIndex > 0) && (index <= aLastIndex)))) {
|
|
|
|
if (index > 0) {
|
|
|
|
// disable the flag
|
|
|
|
aFlagsToUpdate &= ~NS_MATHML_DISPLAYSTYLE;
|
|
|
|
aFlagsValues &= ~NS_MATHML_DISPLAYSTYLE;
|
|
|
|
}
|
2005-02-07 01:57:50 +00:00
|
|
|
PropagatePresentationDataFor(childFrame, aScriptLevelIncrement,
|
|
|
|
aFlagsValues, aFlagsToUpdate);
|
2002-01-10 04:42:55 +00:00
|
|
|
}
|
|
|
|
index++;
|
2003-07-08 11:00:00 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2002-01-10 04:42:55 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
|
2002-02-08 00:58:15 +00:00
|
|
|
// For #2, changing the accent attribute will trigger a re-build of
|
|
|
|
// all automatic data in the embellished hierarchy
|
2002-01-10 04:42:55 +00:00
|
|
|
}
|
|
|
|
|
2000-01-14 08:38:25 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:57:50 +00:00
|
|
|
nsMathMLmoverFrame::InheritAutomaticData(nsIFrame* aParent)
|
2000-01-14 08:38:25 +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);
|
2002-02-01 15:10:50 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY;
|
2000-01-14 08:38:25 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-01-14 08:38:25 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:57:50 +00:00
|
|
|
nsMathMLmoverFrame::TransmitAutomaticData()
|
2002-02-07 04:38:08 +00:00
|
|
|
{
|
|
|
|
// At this stage, all our children are in sync and we can fully
|
|
|
|
// resolve our own mEmbellishData struct
|
|
|
|
//---------------------------------------------------------------------
|
2002-02-01 15:10:50 +00:00
|
|
|
|
2000-01-14 08:38:25 +00:00
|
|
|
/* The REC says:
|
|
|
|
The default value of accent is false, unless overscript
|
|
|
|
is an <mo> element or an embellished operator. If overscript is
|
|
|
|
an <mo> element, the value of its accent attribute is used as
|
|
|
|
the default value of accent. If overscript is an embellished
|
|
|
|
operator, the accent attribute of the <mo> element at its
|
|
|
|
core is used as the default value. As with all attributes, an
|
|
|
|
explicitly given value overrides the default.
|
|
|
|
|
|
|
|
XXX The winner is the outermost in conflicting settings like these:
|
|
|
|
<mover accent='true'>
|
|
|
|
<mi>...</mi>
|
|
|
|
<mo accent='false'> ... </mo>
|
|
|
|
</mover>
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsIFrame* overscriptFrame = nsnull;
|
2002-02-07 04:38:08 +00:00
|
|
|
nsIFrame* baseFrame = mFrames.FirstChild();
|
|
|
|
if (baseFrame)
|
2003-07-08 11:00:00 +00:00
|
|
|
overscriptFrame = baseFrame->GetNextSibling();
|
2002-02-07 04:38:08 +00:00
|
|
|
|
|
|
|
// if our base is an embellished operator, let its state bubble to us (in particular,
|
|
|
|
// this is where we get the flag for NS_MATHML_EMBELLISH_MOVABLELIMITS). Our flags
|
|
|
|
// are reset to the default values of false if the base frame isn't embellished.
|
2005-09-06 23:47:01 +00:00
|
|
|
mPresentationData.baseFrame = baseFrame;
|
2002-02-07 04:38:08 +00:00
|
|
|
GetEmbellishDataFrom(baseFrame, mEmbellishData);
|
2000-01-14 08:38:25 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
// The default value of accent is false, unless the overscript is embellished
|
|
|
|
// and its core <mo> is an accent
|
|
|
|
nsEmbellishData embellishData;
|
|
|
|
GetEmbellishDataFrom(overscriptFrame, embellishData);
|
|
|
|
if (NS_MATHML_EMBELLISH_IS_ACCENT(embellishData.flags))
|
|
|
|
mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER;
|
|
|
|
else
|
|
|
|
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER;
|
|
|
|
|
|
|
|
// if we have an accent attribute, it overrides what the overscript said
|
2006-04-24 05:40:11 +00:00
|
|
|
static nsIContent::AttrValuesArray strings[] =
|
2006-12-26 17:47:52 +00:00
|
|
|
{&nsGkAtoms::_true, &nsGkAtoms::_false, nsnull};
|
|
|
|
switch (mContent->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::accent_,
|
2006-04-24 05:40:11 +00:00
|
|
|
strings, eCaseMatters)) {
|
|
|
|
case 0: mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENTOVER; break;
|
|
|
|
case 1: mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENTOVER; break;
|
|
|
|
}
|
2000-01-14 08:38:25 +00:00
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
// disable the stretch-all flag if we are going to act like a superscript
|
|
|
|
if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
|
|
|
|
!NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
|
|
|
|
mPresentationData.flags &= ~NS_MATHML_STRETCH_ALL_CHILDREN_HORIZONTALLY;
|
|
|
|
|
|
|
|
// Now transmit any change that we want to our children so that they
|
|
|
|
// can update their mPresentationData structs
|
|
|
|
//---------------------------------------------------------------------
|
2000-01-14 08:38:25 +00:00
|
|
|
|
2001-02-02 09:37:14 +00:00
|
|
|
/* The REC says:
|
|
|
|
Within overscript, <mover> always sets displaystyle to "false",
|
|
|
|
but increments scriptlevel by 1 only when accent is "false".
|
2002-02-07 04:38:08 +00:00
|
|
|
|
2001-02-02 09:37:14 +00:00
|
|
|
The TeXBook treats 'over' like a superscript, so p.141 or Rule 13a
|
|
|
|
say it shouldn't be compressed. However, The TeXBook says
|
|
|
|
that math accents and \overline change uncramped styles to their
|
|
|
|
cramped counterparts.
|
2000-01-14 08:38:25 +00:00
|
|
|
*/
|
2002-02-07 04:38:08 +00:00
|
|
|
PRInt32 increment = NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)
|
|
|
|
? 0 : 1;
|
|
|
|
PRUint32 compress = NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)
|
|
|
|
? NS_MATHML_COMPRESSED : 0;
|
2005-02-07 01:57:50 +00:00
|
|
|
PropagatePresentationDataFor(overscriptFrame, increment,
|
2002-02-07 04:38:08 +00:00
|
|
|
~NS_MATHML_DISPLAYSTYLE | compress,
|
|
|
|
NS_MATHML_DISPLAYSTYLE | compress);
|
2002-01-03 23:18:01 +00:00
|
|
|
|
2002-02-01 15:10:50 +00:00
|
|
|
return NS_OK;
|
2000-01-14 08:38:25 +00:00
|
|
|
}
|
1999-12-10 13:02:23 +00:00
|
|
|
|
2000-01-14 08:38:25 +00:00
|
|
|
/*
|
|
|
|
The REC says:
|
|
|
|
* If the base is an operator with movablelimits="true" (or an embellished
|
|
|
|
operator whose <mo> element core has movablelimits="true"), and
|
|
|
|
displaystyle="false", then overscript is drawn in a superscript
|
|
|
|
position. In this case, the accent attribute is ignored. This is
|
|
|
|
often used for limits on symbols such as ∑.
|
|
|
|
|
2001-02-02 09:37:14 +00:00
|
|
|
i.e.:
|
2002-02-07 04:38:08 +00:00
|
|
|
if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
|
2000-01-14 08:38:25 +00:00
|
|
|
!NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
|
|
|
|
// place like superscript
|
|
|
|
}
|
|
|
|
else {
|
2001-02-02 09:37:14 +00:00
|
|
|
// place like overscript
|
2000-01-14 08:38:25 +00:00
|
|
|
}
|
|
|
|
*/
|
1999-12-10 13:02:23 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2006-08-03 23:27:55 +00:00
|
|
|
nsMathMLmoverFrame::Place(nsIRenderingContext& aRenderingContext,
|
|
|
|
PRBool aPlaceOrigin,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
1999-12-10 13:02:23 +00:00
|
|
|
{
|
2002-02-07 04:38:08 +00:00
|
|
|
if ( NS_MATHML_EMBELLISH_IS_MOVABLELIMITS(mEmbellishData.flags) &&
|
2001-02-02 09:37:14 +00:00
|
|
|
!NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
|
|
|
|
// place like superscript
|
2005-02-07 01:57:50 +00:00
|
|
|
return nsMathMLmsupFrame::PlaceSuperScript(GetPresContext(),
|
2001-02-02 09:37:14 +00:00
|
|
|
aRenderingContext,
|
|
|
|
aPlaceOrigin,
|
|
|
|
aDesiredSize,
|
|
|
|
this);
|
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
// Get the children's desired sizes
|
|
|
|
|
|
|
|
nsBoundingMetrics bmBase, bmOver;
|
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 baseSize;
|
|
|
|
nsHTMLReflowMetrics overSize;
|
2000-03-28 09:38:24 +00:00
|
|
|
nsIFrame* overFrame = nsnull;
|
2002-02-07 04:38:08 +00:00
|
|
|
nsIFrame* baseFrame = mFrames.FirstChild();
|
|
|
|
if (baseFrame)
|
2003-07-08 11:00:00 +00:00
|
|
|
overFrame = baseFrame->GetNextSibling();
|
|
|
|
if (!baseFrame || !overFrame || overFrame->GetNextSibling()) {
|
2000-03-28 09:38:24 +00:00
|
|
|
// report an error, encourage people to get their markups in order
|
2001-02-23 16:10:51 +00:00
|
|
|
NS_WARNING("invalid markup");
|
2006-08-03 23:27:55 +00:00
|
|
|
return ReflowError(aRenderingContext, aDesiredSize);
|
1999-09-21 02:12:01 +00:00
|
|
|
}
|
2002-02-07 04:38:08 +00:00
|
|
|
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
|
|
|
|
GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver);
|
1999-12-10 13:02:23 +00:00
|
|
|
|
2005-02-07 01:57:50 +00:00
|
|
|
nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
|
2003-01-22 07:42:20 +00:00
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
////////////////////
|
|
|
|
// Place Children
|
1999-09-21 02:12:01 +00:00
|
|
|
|
2003-05-15 03:42:21 +00:00
|
|
|
aRenderingContext.SetFont(GetStyleFont()->mFont, nsnull);
|
2000-03-28 09:38:24 +00:00
|
|
|
nsCOMPtr<nsIFontMetrics> fm;
|
|
|
|
aRenderingContext.GetFontMetrics(*getter_AddRefs(fm));
|
|
|
|
|
|
|
|
nscoord xHeight = 0;
|
|
|
|
fm->GetXHeight (xHeight);
|
|
|
|
|
|
|
|
nscoord ruleThickness;
|
|
|
|
GetRuleThickness (aRenderingContext, fm, ruleThickness);
|
|
|
|
|
|
|
|
// there are 2 different types of placement depending on
|
|
|
|
// whether we want an accented overscript or not
|
|
|
|
|
|
|
|
nscoord correction = 0;
|
2003-01-22 07:42:20 +00:00
|
|
|
GetItalicCorrection (bmBase, correction);
|
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
nscoord delta1 = 0; // gap between base and overscript
|
|
|
|
nscoord delta2 = 0; // extra space above overscript
|
2002-02-07 04:38:08 +00:00
|
|
|
if (!NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) {
|
2000-03-28 09:38:24 +00:00
|
|
|
// Rule 13a, App. G, TeXbook
|
|
|
|
nscoord bigOpSpacing1, bigOpSpacing3, bigOpSpacing5, dummy;
|
|
|
|
GetBigOpSpacings (fm,
|
|
|
|
bigOpSpacing1, dummy,
|
|
|
|
bigOpSpacing3, dummy,
|
|
|
|
bigOpSpacing5);
|
|
|
|
delta1 = PR_MAX(bigOpSpacing1, (bigOpSpacing3 - bmOver.descent));
|
|
|
|
delta2 = bigOpSpacing5;
|
|
|
|
|
|
|
|
// XXX This is not a TeX rule...
|
2001-02-23 16:10:51 +00:00
|
|
|
// delta1 (as computed above) can become really big when bmOver.descent is
|
2000-03-28 09:38:24 +00:00
|
|
|
// negative, e.g., if the content is &OverBar. In such case, we use the height
|
|
|
|
if (bmOver.descent < 0)
|
|
|
|
delta1 = PR_MAX(bigOpSpacing1, (bigOpSpacing3 - (bmOver.ascent + bmOver.descent)));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Rule 12, App. G, TeXbook
|
2001-02-02 09:37:14 +00:00
|
|
|
// We are going to modify this rule to make it more general.
|
|
|
|
// The idea behind Rule 12 in the TeXBook is to keep the accent
|
|
|
|
// as close to the base as possible, while ensuring that the
|
|
|
|
// distance between the *baseline* of the accent char and
|
|
|
|
// the *baseline* of the base is atleast x-height.
|
|
|
|
// The idea is that for normal use, we would like all the accents
|
|
|
|
// on a line to line up atleast x-height above the baseline
|
|
|
|
// if possible.
|
|
|
|
// When the ascent of the base is >= x-height,
|
|
|
|
// the baseline of the accent char is placed just above the base
|
|
|
|
// (specifically, the baseline of the accent char is placed
|
|
|
|
// above the baseline of the base by the ascent of the base).
|
|
|
|
// For ease of implementation,
|
|
|
|
// this assumes that the font-designer designs accents
|
|
|
|
// in such a way that the bottom of the accent is atleast x-height
|
|
|
|
// above its baseline, otherwise there will be collisions
|
|
|
|
// with the base. Also there should be proper padding between
|
|
|
|
// the bottom of the accent char and its baseline.
|
|
|
|
// The above rule may not be obvious from a first
|
|
|
|
// reading of rule 12 in the TeXBook !!!
|
|
|
|
// The mathml <mover> tag can use accent chars that
|
|
|
|
// do not follow this convention. So we modify TeX's rule
|
|
|
|
// so that TeX's rule gets subsumed for accents that follow
|
|
|
|
// TeX's convention,
|
|
|
|
// while also allowing accents that do not follow the convention :
|
|
|
|
// we try to keep the *bottom* of the accent char atleast x-height
|
|
|
|
// from the baseline of the base char. we also slap on an extra
|
|
|
|
// padding between the accent and base chars.
|
2003-01-22 07:42:20 +00:00
|
|
|
delta1 = ruleThickness + onePixel/2; // we have at least the padding
|
2001-02-02 09:37:14 +00:00
|
|
|
if (bmBase.ascent < xHeight) {
|
2003-01-22 07:42:20 +00:00
|
|
|
// also ensure at least x-height above the baseline of the base
|
2001-02-02 09:37:14 +00:00
|
|
|
delta1 += xHeight - bmBase.ascent;
|
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
delta2 = ruleThickness;
|
|
|
|
}
|
|
|
|
// empty over?
|
2001-02-23 16:10:51 +00:00
|
|
|
if (!(bmOver.ascent + bmOver.descent)) delta1 = 0;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
2001-02-23 16:10:51 +00:00
|
|
|
nscoord dxBase, dxOver = 0;
|
|
|
|
|
|
|
|
// Ad-hoc - This is to override fonts which have ready-made _accent_
|
|
|
|
// glyphs with negative lbearing and rbearing. We want to position
|
|
|
|
// the overscript ourselves
|
|
|
|
nscoord overWidth = bmOver.width;
|
|
|
|
if (!overWidth && (bmOver.rightBearing - bmOver.leftBearing > 0)) {
|
|
|
|
overWidth = bmOver.rightBearing - bmOver.leftBearing;
|
|
|
|
dxOver = -bmOver.leftBearing;
|
|
|
|
}
|
|
|
|
|
2002-02-07 04:38:08 +00:00
|
|
|
if (NS_MATHML_EMBELLISH_IS_ACCENTOVER(mEmbellishData.flags)) {
|
2003-01-22 07:42:20 +00:00
|
|
|
mBoundingMetrics.width = bmBase.width;
|
|
|
|
dxOver += correction + (mBoundingMetrics.width - overWidth)/2;
|
1999-12-10 13:02:23 +00:00
|
|
|
}
|
2000-03-28 09:38:24 +00:00
|
|
|
else {
|
2003-01-22 07:42:20 +00:00
|
|
|
mBoundingMetrics.width = PR_MAX(bmBase.width, overWidth);
|
|
|
|
dxOver += correction/2 + (mBoundingMetrics.width - overWidth)/2;
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
2003-01-22 07:42:20 +00:00
|
|
|
dxBase = (mBoundingMetrics.width - bmBase.width) / 2;
|
|
|
|
|
|
|
|
mBoundingMetrics.ascent =
|
|
|
|
bmOver.ascent + bmOver.descent + delta1 + bmBase.ascent;
|
|
|
|
mBoundingMetrics.descent = bmBase.descent;
|
|
|
|
mBoundingMetrics.leftBearing =
|
|
|
|
PR_MIN(dxBase + bmBase.leftBearing, dxOver + bmOver.leftBearing);
|
|
|
|
mBoundingMetrics.rightBearing =
|
|
|
|
PR_MAX(dxBase + bmBase.rightBearing, dxOver + bmOver.rightBearing);
|
2000-03-28 09:38:24 +00:00
|
|
|
|
|
|
|
aDesiredSize.descent = baseSize.descent;
|
2001-02-02 09:37:14 +00:00
|
|
|
aDesiredSize.ascent =
|
|
|
|
PR_MAX(mBoundingMetrics.ascent + delta2,
|
|
|
|
overSize.ascent + bmOver.descent + delta1 + bmBase.ascent);
|
2000-03-28 09:38:24 +00:00
|
|
|
aDesiredSize.height = aDesiredSize.ascent + aDesiredSize.descent;
|
|
|
|
aDesiredSize.width = mBoundingMetrics.width;
|
2003-01-22 07:42:20 +00:00
|
|
|
aDesiredSize.mBoundingMetrics = mBoundingMetrics;
|
2000-03-28 09:38:24 +00:00
|
|
|
|
|
|
|
mReference.x = 0;
|
|
|
|
mReference.y = aDesiredSize.ascent;
|
|
|
|
|
|
|
|
if (aPlaceOrigin) {
|
|
|
|
// place base
|
2003-01-22 07:42:20 +00:00
|
|
|
nscoord dy = aDesiredSize.ascent - baseSize.ascent;
|
2005-02-07 01:57:50 +00:00
|
|
|
FinishReflowChild (baseFrame, GetPresContext(), nsnull, baseSize, dxBase, dy, 0);
|
2000-03-28 09:38:24 +00:00
|
|
|
// place overscript
|
2003-01-22 07:42:20 +00:00
|
|
|
dy = aDesiredSize.ascent -
|
|
|
|
mBoundingMetrics.ascent + bmOver.ascent - overSize.ascent;
|
2005-02-07 01:57:50 +00:00
|
|
|
FinishReflowChild (overFrame, GetPresContext(), nsnull, overSize, dxOver, dy, 0);
|
2000-03-28 09:38:24 +00:00
|
|
|
}
|
1999-09-21 02:12:01 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|