2007-06-12 10:10:23 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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 06:12:01 +04:00
|
|
|
|
2013-08-31 01:37:12 +04:00
|
|
|
#include "nsMathMLmoFrame.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2011-04-08 05:04:40 +04:00
|
|
|
#include "nsRenderingContext.h"
|
2006-09-16 00:13:01 +04:00
|
|
|
#include "nsContentUtils.h"
|
2013-08-22 22:32:52 +04:00
|
|
|
#include "nsFrameSelection.h"
|
2013-08-31 01:37:12 +04:00
|
|
|
#include "nsMathMLElement.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
1999-09-21 06:12:01 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// <mo> -- operator, fence, or separator - implementation
|
|
|
|
//
|
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
// additional style context to be used by our MathMLChar.
|
|
|
|
#define NS_MATHML_CHAR_STYLE_CONTEXT_INDEX 0
|
|
|
|
|
2005-11-11 05:36:29 +03:00
|
|
|
nsIFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewMathMLmoFrame(nsIPresShell* aPresShell, nsStyleContext *aContext)
|
1999-09-21 06:12:01 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsMathMLmoFrame(aContext);
|
1999-09-21 06:12:01 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsMathMLmoFrame)
|
|
|
|
|
1999-09-21 06:12:01 +04:00
|
|
|
nsMathMLmoFrame::~nsMathMLmoFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t kApplyFunction = char16_t(0x2061);
|
|
|
|
static const char16_t kInvisibleTimes = char16_t(0x2062);
|
2014-02-10 17:58:33 +04:00
|
|
|
static const char16_t kInvisibleSeparator = char16_t(0x2063);
|
|
|
|
static const char16_t kInvisiblePlus = char16_t(0x2064);
|
2002-08-13 03:30:35 +04:00
|
|
|
|
2006-08-15 08:49:43 +04:00
|
|
|
eMathMLFrameType
|
|
|
|
nsMathMLmoFrame::GetMathMLFrameType()
|
2002-08-13 03:30:35 +04:00
|
|
|
{
|
2005-09-07 03:47:01 +04:00
|
|
|
return NS_MATHML_OPERATOR_IS_INVISIBLE(mFlags)
|
2006-08-15 08:49:43 +04:00
|
|
|
? eMathMLFrameType_OperatorInvisible
|
|
|
|
: eMathMLFrameType_OperatorOrdinary;
|
2002-08-13 03:30:35 +04:00
|
|
|
}
|
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
// since a mouse click implies selection, we cannot just rely on the
|
|
|
|
// frame's state bit in our child text frame. So we will first check
|
|
|
|
// its selected state bit, and use this little helper to double check.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLmoFrame::IsFrameInSelection(nsIFrame* aFrame)
|
2002-04-02 08:15:22 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aFrame, "null arg");
|
2011-12-20 13:15:41 +04:00
|
|
|
if (!aFrame || !aFrame->IsSelected())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2002-04-02 08:15:22 +04:00
|
|
|
|
2007-11-22 23:47:33 +03:00
|
|
|
const nsFrameSelection* frameSelection = aFrame->GetConstFrameSelection();
|
|
|
|
SelectionDetails* details =
|
2011-10-17 18:59:28 +04:00
|
|
|
frameSelection->LookUpSelection(aFrame->GetContent(), 0, 1, true);
|
2006-04-26 06:01:07 +04:00
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
if (!details)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2002-04-02 08:15:22 +04:00
|
|
|
|
|
|
|
while (details) {
|
|
|
|
SelectionDetails* next = details->mNext;
|
|
|
|
delete details;
|
|
|
|
details = next;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2002-04-02 08:15:22 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-03-14 07:05:43 +03:00
|
|
|
nsMathMLmoFrame::UseMathMLChar()
|
|
|
|
{
|
|
|
|
return (NS_MATHML_OPERATOR_GET_FORM(mFlags) &&
|
|
|
|
NS_MATHML_OPERATOR_IS_MUTABLE(mFlags)) ||
|
2014-03-19 21:05:02 +04:00
|
|
|
NS_MATHML_OPERATOR_IS_CENTERED(mFlags);
|
2008-03-14 07:05:43 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsMathMLmoFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1999-09-21 06:12:01 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool useMathMLChar = UseMathMLChar();
|
2002-04-02 08:15:22 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
if (!useMathMLChar) {
|
|
|
|
// let the base class do everything
|
2013-02-14 15:08:08 +04:00
|
|
|
nsMathMLTokenFrame::BuildDisplayList(aBuilder, aDirtyRect, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
} else {
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
// make our char selected if our inner child text frame is selected
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isSelected = false;
|
2002-04-02 08:15:22 +04:00
|
|
|
nsRect selectedRect;
|
|
|
|
nsIFrame* firstChild = mFrames.FirstChild();
|
2005-02-07 04:57:50 +03:00
|
|
|
if (IsFrameInSelection(firstChild)) {
|
2012-11-11 02:09:26 +04:00
|
|
|
mMathMLChar.GetRect(selectedRect);
|
|
|
|
// add a one pixel border (it renders better for operators like minus)
|
|
|
|
selectedRect.Inflate(nsPresContext::CSSPixelsToAppUnits(1));
|
2011-10-17 18:59:28 +04:00
|
|
|
isSelected = true;
|
2002-04-02 08:15:22 +04:00
|
|
|
}
|
2013-02-14 15:08:08 +04:00
|
|
|
mMathMLChar.Display(aBuilder, this, aLists, 0, isSelected ? &selectedRect : nullptr);
|
2006-01-26 05:29:17 +03:00
|
|
|
|
2012-06-25 23:59:42 +04:00
|
|
|
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
|
2000-01-18 07:35:37 +03:00
|
|
|
// for visual debug
|
2013-02-14 15:08:08 +04:00
|
|
|
DisplayBoundingMetrics(aBuilder, this, mReference, mBoundingMetrics, aLists);
|
2000-01-18 07:35:37 +03:00
|
|
|
#endif
|
1999-10-12 06:12:36 +04:00
|
|
|
}
|
1999-09-21 06:12:01 +04:00
|
|
|
}
|
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
// get the text that we enclose and setup our nsMathMLChar
|
|
|
|
void
|
2008-01-27 05:49:47 +03:00
|
|
|
nsMathMLmoFrame::ProcessTextData()
|
1999-10-12 06:12:36 +04:00
|
|
|
{
|
|
|
|
mFlags = 0;
|
|
|
|
|
2005-09-07 03:47:01 +04:00
|
|
|
nsAutoString data;
|
2015-05-22 21:16:20 +03:00
|
|
|
nsContentUtils::GetNodeTextContent(mContent, false, data);
|
2014-03-20 23:51:16 +04:00
|
|
|
|
2012-08-31 05:32:02 +04:00
|
|
|
data.CompressWhitespace();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t length = data.Length();
|
2014-01-04 19:02:17 +04:00
|
|
|
char16_t ch = (length == 0) ? char16_t('\0') : data[0];
|
2005-09-07 03:47:01 +04:00
|
|
|
|
|
|
|
if ((length == 1) &&
|
2014-03-19 21:05:02 +04:00
|
|
|
(ch == kApplyFunction ||
|
2014-02-10 17:58:33 +04:00
|
|
|
ch == kInvisibleSeparator ||
|
|
|
|
ch == kInvisiblePlus ||
|
2005-09-07 03:47:01 +04:00
|
|
|
ch == kInvisibleTimes)) {
|
|
|
|
mFlags |= NS_MATHML_OPERATOR_INVISIBLE;
|
|
|
|
}
|
|
|
|
|
2014-03-19 21:05:02 +04:00
|
|
|
// don't bother doing anything special if we don't have a single child
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
2014-03-19 21:05:02 +04:00
|
|
|
if (mFrames.GetLength() != 1) {
|
2005-09-07 03:47:01 +04:00
|
|
|
data.Truncate(); // empty data to reset the char
|
2006-09-25 04:08:41 +04:00
|
|
|
mMathMLChar.SetData(presContext, data);
|
2014-04-24 23:30:00 +04:00
|
|
|
ResolveMathMLCharStyle(presContext, mContent, mStyleContext, &mMathMLChar);
|
2005-09-07 03:47:01 +04:00
|
|
|
return;
|
|
|
|
}
|
2002-02-27 04:35:27 +03:00
|
|
|
|
|
|
|
// special... in math mode, the usual minus sign '-' looks too short, so
|
|
|
|
// what we do here is to remap <mo>-</mo> to the official Unicode minus
|
|
|
|
// sign (U+2212) which looks much better. For background on this, see
|
|
|
|
// http://groups.google.com/groups?hl=en&th=66488daf1ade7635&rnum=1
|
2005-09-07 03:47:01 +04:00
|
|
|
if (1 == length && ch == '-') {
|
2006-10-02 09:32:12 +04:00
|
|
|
ch = 0x2212;
|
|
|
|
data = ch;
|
2002-02-27 04:35:27 +03:00
|
|
|
}
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
// cache the special bits: mutable, accent, movablelimits, centered.
|
|
|
|
// we need to do this in anticipation of other requirements, and these
|
|
|
|
// bits don't change. Do not reset these bits unless the text gets changed.
|
|
|
|
|
|
|
|
// lookup all the forms under which the operator is listed in the dictionary,
|
|
|
|
// and record whether the operator has accent="true" or movablelimits="true"
|
|
|
|
nsOperatorFlags flags[4];
|
|
|
|
float lspace[4], rspace[4];
|
|
|
|
nsMathMLOperators::LookupOperators(data, flags, lspace, rspace);
|
|
|
|
nsOperatorFlags allFlags =
|
|
|
|
flags[NS_MATHML_OPERATOR_FORM_INFIX] |
|
|
|
|
flags[NS_MATHML_OPERATOR_FORM_POSTFIX] |
|
|
|
|
flags[NS_MATHML_OPERATOR_FORM_PREFIX];
|
|
|
|
|
|
|
|
mFlags |= allFlags & NS_MATHML_OPERATOR_ACCENT;
|
|
|
|
mFlags |= allFlags & NS_MATHML_OPERATOR_MOVABLELIMITS;
|
|
|
|
|
|
|
|
// see if this is an operator that should be centered to cater for
|
|
|
|
// fonts that are not math-aware
|
2002-02-27 04:35:27 +03:00
|
|
|
if (1 == length) {
|
2002-02-07 07:38:08 +03:00
|
|
|
if ((ch == '+') || (ch == '=') || (ch == '*') ||
|
2006-10-02 09:32:12 +04:00
|
|
|
(ch == 0x2212) || // −
|
2003-04-22 07:32:06 +04:00
|
|
|
(ch == 0x2264) || // ≤
|
|
|
|
(ch == 0x2265) || // ≥
|
2002-02-07 07:38:08 +03:00
|
|
|
(ch == 0x00D7)) { // ×
|
|
|
|
mFlags |= NS_MATHML_OPERATOR_CENTERED;
|
|
|
|
}
|
2000-05-08 11:31:05 +04:00
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
// cache the operator
|
2006-09-25 04:08:41 +04:00
|
|
|
mMathMLChar.SetData(presContext, data);
|
2002-04-02 08:15:22 +04:00
|
|
|
|
|
|
|
// cache the native direction -- beware of bug 133429...
|
|
|
|
// mEmbellishData.direction must always retain our native direction, whereas
|
|
|
|
// mMathMLChar.GetStretchDirection() may change later, when Stretch() is called
|
|
|
|
mEmbellishData.direction = mMathMLChar.GetStretchDirection();
|
2013-06-04 16:17:45 +04:00
|
|
|
|
|
|
|
bool isMutable =
|
|
|
|
NS_MATHML_OPERATOR_IS_LARGEOP(allFlags) ||
|
|
|
|
(mEmbellishData.direction != NS_STRETCH_DIRECTION_UNSUPPORTED);
|
|
|
|
if (isMutable)
|
|
|
|
mFlags |= NS_MATHML_OPERATOR_MUTABLE;
|
|
|
|
|
2014-04-24 23:30:00 +04:00
|
|
|
ResolveMathMLCharStyle(presContext, mContent, mStyleContext, &mMathMLChar);
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
// get our 'form' and lookup in the Operator Dictionary to fetch
|
2002-02-27 04:35:27 +03:00
|
|
|
// our default data that may come from there. Then complete our setup
|
|
|
|
// using attributes that we may have. To stay in sync, this function is
|
|
|
|
// called very often. We depend on many things that may change around us.
|
|
|
|
// However, we re-use unchanged values.
|
2002-02-07 07:38:08 +03:00
|
|
|
void
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLmoFrame::ProcessOperatorData()
|
2000-03-28 13:38:24 +04:00
|
|
|
{
|
2002-02-07 07:38:08 +03:00
|
|
|
// if we have been here before, we will just use our cached form
|
|
|
|
nsOperatorFlags form = NS_MATHML_OPERATOR_GET_FORM(mFlags);
|
|
|
|
nsAutoString value;
|
2014-10-25 10:29:00 +04:00
|
|
|
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
// special bits are always kept in mFlags.
|
|
|
|
// remember the mutable bit from ProcessTextData().
|
|
|
|
// Some chars are listed under different forms in the dictionary,
|
|
|
|
// and there could be a form under which the char is mutable.
|
|
|
|
// If the char is the core of an embellished container, we will keep
|
|
|
|
// it mutable irrespective of the form of the embellished container.
|
|
|
|
// Also remember the other special bits that we want to carry forward.
|
|
|
|
mFlags &= NS_MATHML_OPERATOR_MUTABLE |
|
|
|
|
NS_MATHML_OPERATOR_ACCENT |
|
|
|
|
NS_MATHML_OPERATOR_MOVABLELIMITS |
|
2005-09-07 03:47:01 +04:00
|
|
|
NS_MATHML_OPERATOR_CENTERED |
|
|
|
|
NS_MATHML_OPERATOR_INVISIBLE;
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
if (!mEmbellishData.coreFrame) {
|
|
|
|
// i.e., we haven't been here before, the default form is infix
|
|
|
|
form = NS_MATHML_OPERATOR_FORM_INFIX;
|
|
|
|
|
|
|
|
// reset everything so that we don't keep outdated values around
|
|
|
|
// in case of dynamic changes
|
|
|
|
mEmbellishData.flags = 0;
|
2012-07-30 18:20:58 +04:00
|
|
|
mEmbellishData.coreFrame = nullptr;
|
2011-12-22 02:21:59 +04:00
|
|
|
mEmbellishData.leadingSpace = 0;
|
|
|
|
mEmbellishData.trailingSpace = 0;
|
2002-04-02 08:15:22 +04:00
|
|
|
if (mMathMLChar.Length() != 1)
|
|
|
|
mEmbellishData.direction = NS_STRETCH_DIRECTION_UNSUPPORTED;
|
|
|
|
// else... retain the native direction obtained in ProcessTextData()
|
2002-02-07 07:38:08 +03:00
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
if (!mFrames.FirstChild()) {
|
2002-02-07 07:38:08 +03:00
|
|
|
return;
|
2002-04-02 08:15:22 +04:00
|
|
|
}
|
1999-12-10 16:02:23 +03:00
|
|
|
|
2002-01-05 04:15:04 +03:00
|
|
|
mEmbellishData.flags |= NS_MATHML_EMBELLISH_OPERATOR;
|
2002-01-28 01:10:45 +03:00
|
|
|
mEmbellishData.coreFrame = this;
|
2002-01-05 04:15:04 +03:00
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
// there are two particular things that we also need to record so that if our
|
2001-02-23 19:10:51 +03:00
|
|
|
// parent is <mover>, <munder>, or <munderover>, they will treat us properly:
|
|
|
|
// 1) do we have accent="true"
|
|
|
|
// 2) do we have movablelimits="true"
|
2002-02-07 07:38:08 +03:00
|
|
|
|
2001-02-23 19:10:51 +03:00
|
|
|
// they need the extra information to decide how to treat their scripts/limits
|
|
|
|
// (note: <mover>, <munder>, or <munderover> need not necessarily be our
|
|
|
|
// direct parent -- case of embellished operators)
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
// default values from the Operator Dictionary were obtained in ProcessTextData()
|
|
|
|
// and these special bits are always kept in mFlags
|
|
|
|
if (NS_MATHML_OPERATOR_IS_ACCENT(mFlags))
|
|
|
|
mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
|
|
|
|
if (NS_MATHML_OPERATOR_IS_MOVABLELIMITS(mFlags))
|
|
|
|
mEmbellishData.flags |= NS_MATHML_EMBELLISH_MOVABLELIMITS;
|
|
|
|
|
2001-02-23 19:10:51 +03:00
|
|
|
// see if the accent attribute is there
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::accent_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (value.EqualsLiteral("true"))
|
|
|
|
mEmbellishData.flags |= NS_MATHML_EMBELLISH_ACCENT;
|
|
|
|
else if (value.EqualsLiteral("false"))
|
|
|
|
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_ACCENT;
|
|
|
|
|
2001-02-23 19:10:51 +03:00
|
|
|
// see if the movablelimits attribute is there
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::movablelimits_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (value.EqualsLiteral("true"))
|
|
|
|
mEmbellishData.flags |= NS_MATHML_EMBELLISH_MOVABLELIMITS;
|
|
|
|
else if (value.EqualsLiteral("false"))
|
|
|
|
mEmbellishData.flags &= ~NS_MATHML_EMBELLISH_MOVABLELIMITS;
|
1999-12-10 16:02:23 +03:00
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
// ---------------------------------------------------------------------
|
|
|
|
// we will be called again to re-sync the rest of our state next time...
|
|
|
|
// (nobody needs the other values below at this stage)
|
|
|
|
mFlags |= form;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-31 01:11:41 +04:00
|
|
|
nsPresContext* presContext = PresContext();
|
2005-02-07 04:57:50 +03:00
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
// beware of bug 133814 - there is a two-way dependency in the
|
|
|
|
// embellished hierarchy: our embellished ancestors need to set
|
|
|
|
// their flags based on some of our state (set above), and here we
|
|
|
|
// need to re-sync our 'form' depending on our outermost embellished
|
|
|
|
// container. A null form here means that an earlier attempt to stretch
|
|
|
|
// our mMathMLChar failed, in which case we don't bother re-stretching again
|
|
|
|
if (form) {
|
2002-02-07 07:38:08 +03:00
|
|
|
// get our outermost embellished container and its parent.
|
|
|
|
// (we ensure that we are the core, not just a sibling of the core)
|
|
|
|
nsIFrame* embellishAncestor = this;
|
|
|
|
nsEmbellishData embellishData;
|
|
|
|
nsIFrame* parentAncestor = this;
|
|
|
|
do {
|
|
|
|
embellishAncestor = parentAncestor;
|
2003-07-08 15:00:00 +04:00
|
|
|
parentAncestor = embellishAncestor->GetParent();
|
2002-02-07 07:38:08 +03:00
|
|
|
GetEmbellishDataFrom(parentAncestor, embellishData);
|
|
|
|
} while (embellishData.coreFrame == this);
|
|
|
|
|
|
|
|
// flag if we have an embellished ancestor
|
|
|
|
if (embellishAncestor != this)
|
|
|
|
mFlags |= NS_MATHML_OPERATOR_EMBELLISH_ANCESTOR;
|
|
|
|
else
|
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_EMBELLISH_ANCESTOR;
|
|
|
|
|
|
|
|
// find the position of our outermost embellished container w.r.t
|
2009-10-02 20:27:37 +04:00
|
|
|
// its siblings.
|
2000-05-08 11:31:05 +04:00
|
|
|
|
2003-07-08 15:00:00 +04:00
|
|
|
nsIFrame* nextSibling = embellishAncestor->GetNextSibling();
|
2009-10-02 20:27:37 +04:00
|
|
|
nsIFrame* prevSibling = embellishAncestor->GetPrevSibling();
|
1999-10-12 06:12:36 +04:00
|
|
|
|
2014-04-04 19:54:00 +04:00
|
|
|
// flag to distinguish from a real infix. Set for (embellished) operators
|
|
|
|
// that live in (inferred) mrows.
|
|
|
|
nsIMathMLFrame* mathAncestor = do_QueryFrame(parentAncestor);
|
|
|
|
bool zeroSpacing = false;
|
|
|
|
if (mathAncestor) {
|
|
|
|
zeroSpacing = !mathAncestor->IsMrowLike();
|
|
|
|
} else {
|
|
|
|
nsMathMLmathBlockFrame* blockFrame = do_QueryFrame(parentAncestor);
|
|
|
|
if (blockFrame) {
|
|
|
|
zeroSpacing = !blockFrame->IsMrowLike();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (zeroSpacing) {
|
2002-02-07 07:38:08 +03:00
|
|
|
mFlags |= NS_MATHML_OPERATOR_EMBELLISH_ISOLATED;
|
2014-04-04 19:54:00 +04:00
|
|
|
} else {
|
2002-02-07 07:38:08 +03:00
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_EMBELLISH_ISOLATED;
|
2014-04-04 19:54:00 +04:00
|
|
|
}
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
// find our form
|
2002-04-02 08:15:22 +04:00
|
|
|
form = NS_MATHML_OPERATOR_FORM_INFIX;
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::form, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2004-04-30 17:23:43 +04:00
|
|
|
if (value.EqualsLiteral("prefix"))
|
2002-02-07 07:38:08 +03:00
|
|
|
form = NS_MATHML_OPERATOR_FORM_PREFIX;
|
2004-04-30 17:23:43 +04:00
|
|
|
else if (value.EqualsLiteral("postfix"))
|
2002-02-07 07:38:08 +03:00
|
|
|
form = NS_MATHML_OPERATOR_FORM_POSTFIX;
|
2002-01-05 04:15:04 +03:00
|
|
|
}
|
|
|
|
else {
|
2002-02-07 07:38:08 +03:00
|
|
|
// set our form flag depending on the position
|
|
|
|
if (!prevSibling && nextSibling)
|
|
|
|
form = NS_MATHML_OPERATOR_FORM_PREFIX;
|
|
|
|
else if (prevSibling && !nextSibling)
|
|
|
|
form = NS_MATHML_OPERATOR_FORM_POSTFIX;
|
2002-01-05 04:15:04 +03:00
|
|
|
}
|
2002-04-02 08:15:22 +04:00
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_FORM; // clear the old form bits
|
|
|
|
mFlags |= form;
|
2002-01-05 04:15:04 +03:00
|
|
|
|
2012-06-27 02:42:56 +04:00
|
|
|
// Use the default value suggested by the MathML REC.
|
|
|
|
// http://www.w3.org/TR/MathML/chapter3.html#presm.mo.attrs
|
|
|
|
// thickmathspace = 5/18em
|
2013-04-28 14:02:35 +04:00
|
|
|
float lspace = 5.0f/18.0f;
|
|
|
|
float rspace = 5.0f/18.0f;
|
2014-03-19 21:05:02 +04:00
|
|
|
// lookup the operator dictionary
|
|
|
|
nsAutoString data;
|
|
|
|
mMathMLChar.GetData(data);
|
|
|
|
nsMathMLOperators::LookupOperator(data, form, &mFlags, &lspace, &rspace);
|
2014-04-04 19:54:00 +04:00
|
|
|
// Spacing is zero if our outermost embellished operator is not in an
|
|
|
|
// inferred mrow.
|
|
|
|
if (!NS_MATHML_OPERATOR_EMBELLISH_IS_ISOLATED(mFlags) &&
|
|
|
|
(lspace || rspace)) {
|
2012-06-27 02:42:56 +04:00
|
|
|
// Cache the default values of lspace and rspace.
|
2002-02-07 07:38:08 +03:00
|
|
|
// since these values are relative to the 'em' unit, convert to twips now
|
|
|
|
nscoord em;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFontMetrics> fm;
|
2014-10-25 10:29:00 +04:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
|
|
|
fontSizeInflation);
|
2002-02-07 07:38:08 +03:00
|
|
|
GetEmHeight(fm, em);
|
|
|
|
|
2011-12-22 02:21:59 +04:00
|
|
|
mEmbellishData.leadingSpace = NSToCoordRound(lspace * em);
|
|
|
|
mEmbellishData.trailingSpace = NSToCoordRound(rspace * em);
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
// tuning if we don't want too much extra space when we are a script.
|
|
|
|
// (with its fonts, TeX sets lspace=0 & rspace=0 as soon as scriptlevel>0.
|
|
|
|
// Our fonts can be anything, so...)
|
2014-04-04 19:54:00 +04:00
|
|
|
if (StyleFont()->mScriptLevel > 0 &&
|
|
|
|
!NS_MATHML_OPERATOR_HAS_EMBELLISH_ANCESTOR(mFlags)) {
|
|
|
|
mEmbellishData.leadingSpace /= 2;
|
|
|
|
mEmbellishData.trailingSpace /= 2;
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
1999-09-21 06:12:01 +04:00
|
|
|
}
|
1999-12-10 16:02:23 +03:00
|
|
|
}
|
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
// If we are an accent without explicit lspace="." or rspace=".",
|
2011-12-22 02:21:59 +04:00
|
|
|
// we will ignore our default leading/trailing space
|
2000-01-26 09:49:38 +03:00
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// lspace
|
|
|
|
//
|
|
|
|
// "Specifies the leading space appearing before the operator"
|
|
|
|
//
|
|
|
|
// values: length
|
|
|
|
// default: set by dictionary (thickmathspace)
|
|
|
|
//
|
2013-01-07 07:24:13 +04:00
|
|
|
// XXXfredw Support for negative and relative values is not implemented
|
|
|
|
// (bug 805926).
|
|
|
|
// Relative values will give a multiple of the current leading space,
|
|
|
|
// which is not necessarily the default one.
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
2011-12-22 02:21:59 +04:00
|
|
|
nscoord leadingSpace = mEmbellishData.leadingSpace;
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::lspace_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2000-01-26 09:49:38 +03:00
|
|
|
nsCSSValue cssValue;
|
2012-12-27 20:12:05 +04:00
|
|
|
if (nsMathMLElement::ParseNumericValue(value, cssValue, 0,
|
|
|
|
mContent->OwnerDoc())) {
|
2001-02-23 19:10:51 +03:00
|
|
|
if ((eCSSUnit_Number == cssValue.GetUnit()) && !cssValue.GetFloatValue())
|
2011-12-22 02:21:59 +04:00
|
|
|
leadingSpace = 0;
|
2000-03-28 13:38:24 +04:00
|
|
|
else if (cssValue.IsLengthUnit())
|
2014-10-25 10:29:00 +04:00
|
|
|
leadingSpace = CalcLength(presContext, mStyleContext, cssValue,
|
|
|
|
fontSizeInflation);
|
2011-12-22 02:21:59 +04:00
|
|
|
mFlags |= NS_MATHML_OPERATOR_LSPACE_ATTR;
|
2000-01-26 09:49:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// rspace
|
|
|
|
//
|
|
|
|
// "Specifies the trailing space appearing after the operator"
|
|
|
|
//
|
|
|
|
// values: length
|
|
|
|
// default: set by dictionary (thickmathspace)
|
|
|
|
//
|
2013-01-07 07:24:13 +04:00
|
|
|
// XXXfredw Support for negative and relative values is not implemented
|
|
|
|
// (bug 805926).
|
|
|
|
// Relative values will give a multiple of the current leading space,
|
|
|
|
// which is not necessarily the default one.
|
2012-05-16 02:30:14 +04:00
|
|
|
//
|
2011-12-22 02:21:59 +04:00
|
|
|
nscoord trailingSpace = mEmbellishData.trailingSpace;
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rspace_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2000-01-26 09:49:38 +03:00
|
|
|
nsCSSValue cssValue;
|
2012-12-27 20:12:05 +04:00
|
|
|
if (nsMathMLElement::ParseNumericValue(value, cssValue, 0,
|
|
|
|
mContent->OwnerDoc())) {
|
2001-02-23 19:10:51 +03:00
|
|
|
if ((eCSSUnit_Number == cssValue.GetUnit()) && !cssValue.GetFloatValue())
|
2011-12-22 02:21:59 +04:00
|
|
|
trailingSpace = 0;
|
2000-03-28 13:38:24 +04:00
|
|
|
else if (cssValue.IsLengthUnit())
|
2014-10-25 10:29:00 +04:00
|
|
|
trailingSpace = CalcLength(presContext, mStyleContext, cssValue,
|
|
|
|
fontSizeInflation);
|
2011-12-22 02:21:59 +04:00
|
|
|
mFlags |= NS_MATHML_OPERATOR_RSPACE_ATTR;
|
2000-01-26 09:49:38 +03:00
|
|
|
}
|
|
|
|
}
|
2000-01-14 11:38:25 +03:00
|
|
|
|
2002-02-27 04:35:27 +03:00
|
|
|
// little extra tuning to round lspace & rspace to at least a pixel so that
|
|
|
|
// operators don't look as if they are colliding with their operands
|
2011-12-22 02:21:59 +04:00
|
|
|
if (leadingSpace || trailingSpace) {
|
2007-02-07 10:46:44 +03:00
|
|
|
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
|
2011-12-22 02:21:59 +04:00
|
|
|
if (leadingSpace && leadingSpace < onePixel)
|
|
|
|
leadingSpace = onePixel;
|
|
|
|
if (trailingSpace && trailingSpace < onePixel)
|
|
|
|
trailingSpace = onePixel;
|
2002-02-27 04:35:27 +03:00
|
|
|
}
|
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
// the values that we get from our attributes override the dictionary
|
2011-12-22 02:21:59 +04:00
|
|
|
mEmbellishData.leadingSpace = leadingSpace;
|
|
|
|
mEmbellishData.trailingSpace = trailingSpace;
|
2002-01-05 04:15:04 +03:00
|
|
|
|
2002-02-27 04:35:27 +03:00
|
|
|
// Now see if there are user-defined attributes that override the dictionary.
|
2015-08-24 13:44:00 +03:00
|
|
|
// XXX Bug 1197771 - forcing an attribute to true when it is false in the
|
|
|
|
// dictionary can cause conflicts in the rest of the stretching algorithms
|
|
|
|
// (e.g. all largeops are assumed to have a vertical direction)
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
// For each attribute overriden by the user, turn off its bit flag.
|
|
|
|
// symmetric|movablelimits|separator|largeop|accent|fence|stretchy|form
|
2006-09-25 04:08:41 +04:00
|
|
|
// special: accent and movablelimits are handled above,
|
2002-02-07 07:38:08 +03:00
|
|
|
// don't process them here
|
|
|
|
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::stretchy_, value);
|
2010-08-20 07:44:07 +04:00
|
|
|
if (value.EqualsLiteral("false")) {
|
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_STRETCHY;
|
|
|
|
} else if (value.EqualsLiteral("true")) {
|
|
|
|
mFlags |= NS_MATHML_OPERATOR_STRETCHY;
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
|
|
|
if (NS_MATHML_OPERATOR_IS_FENCE(mFlags)) {
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::fence_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (value.EqualsLiteral("false"))
|
2002-02-07 07:38:08 +03:00
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_FENCE;
|
2015-07-16 12:41:00 +03:00
|
|
|
else
|
|
|
|
mEmbellishData.flags |= NS_MATHML_EMBELLISH_FENCE;
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::largeop_, value);
|
2010-08-20 07:44:07 +04:00
|
|
|
if (value.EqualsLiteral("false")) {
|
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_LARGEOP;
|
|
|
|
} else if (value.EqualsLiteral("true")) {
|
|
|
|
mFlags |= NS_MATHML_OPERATOR_LARGEOP;
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
|
|
|
if (NS_MATHML_OPERATOR_IS_SEPARATOR(mFlags)) {
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::separator_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (value.EqualsLiteral("false"))
|
2002-02-07 07:38:08 +03:00
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_SEPARATOR;
|
2015-07-16 12:41:00 +03:00
|
|
|
else
|
|
|
|
mEmbellishData.flags |= NS_MATHML_EMBELLISH_SEPARATOR;
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::symmetric_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (value.EqualsLiteral("false"))
|
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_SYMMETRIC;
|
|
|
|
else if (value.EqualsLiteral("true"))
|
|
|
|
mFlags |= NS_MATHML_OPERATOR_SYMMETRIC;
|
2002-02-07 07:38:08 +03:00
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
|
|
|
|
// minsize
|
|
|
|
//
|
|
|
|
// "Specifies the minimum size of the operator when stretchy"
|
|
|
|
//
|
|
|
|
// values: length
|
|
|
|
// default: set by dictionary (1em)
|
|
|
|
//
|
|
|
|
// We don't allow negative values.
|
|
|
|
// Note: Contrary to other "length" values, unitless and percentage do not
|
|
|
|
// give a multiple of the defaut value but a multiple of the operator at
|
|
|
|
// normal size.
|
|
|
|
//
|
2013-04-28 14:02:35 +04:00
|
|
|
mMinSize = 0;
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::minsize_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2000-01-26 09:49:38 +03:00
|
|
|
nsCSSValue cssValue;
|
2012-05-16 02:30:14 +04:00
|
|
|
if (nsMathMLElement::ParseNumericValue(value, cssValue,
|
|
|
|
nsMathMLElement::
|
2012-12-27 20:12:05 +04:00
|
|
|
PARSE_ALLOW_UNITLESS,
|
|
|
|
mContent->OwnerDoc())) {
|
2000-01-26 09:49:38 +03:00
|
|
|
nsCSSUnit unit = cssValue.GetUnit();
|
|
|
|
if (eCSSUnit_Number == unit)
|
|
|
|
mMinSize = cssValue.GetFloatValue();
|
|
|
|
else if (eCSSUnit_Percent == unit)
|
|
|
|
mMinSize = cssValue.GetPercentValue();
|
|
|
|
else if (eCSSUnit_Null != unit) {
|
2014-10-25 10:29:00 +04:00
|
|
|
mMinSize = float(CalcLength(presContext, mStyleContext, cssValue,
|
|
|
|
fontSizeInflation));
|
2008-03-14 07:05:43 +03:00
|
|
|
mFlags |= NS_MATHML_OPERATOR_MINSIZE_ABSOLUTE;
|
2000-01-26 09:49:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-16 02:30:14 +04:00
|
|
|
// maxsize
|
|
|
|
//
|
|
|
|
// "Specifies the maximum size of the operator when stretchy"
|
|
|
|
//
|
|
|
|
// values: length | "infinity"
|
|
|
|
// default: set by dictionary (infinity)
|
|
|
|
//
|
|
|
|
// We don't allow negative values.
|
|
|
|
// Note: Contrary to other "length" values, unitless and percentage do not
|
|
|
|
// give a multiple of the defaut value but a multiple of the operator at
|
|
|
|
// normal size.
|
|
|
|
//
|
2008-03-14 07:05:43 +03:00
|
|
|
mMaxSize = NS_MATHML_OPERATOR_SIZE_INFINITY;
|
2014-01-15 19:07:06 +04:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::maxsize_, value);
|
2005-10-28 15:25:24 +04:00
|
|
|
if (!value.IsEmpty()) {
|
2000-01-26 09:49:38 +03:00
|
|
|
nsCSSValue cssValue;
|
2012-05-16 02:30:14 +04:00
|
|
|
if (nsMathMLElement::ParseNumericValue(value, cssValue,
|
|
|
|
nsMathMLElement::
|
2012-12-27 20:12:05 +04:00
|
|
|
PARSE_ALLOW_UNITLESS,
|
|
|
|
mContent->OwnerDoc())) {
|
2000-01-26 09:49:38 +03:00
|
|
|
nsCSSUnit unit = cssValue.GetUnit();
|
|
|
|
if (eCSSUnit_Number == unit)
|
|
|
|
mMaxSize = cssValue.GetFloatValue();
|
|
|
|
else if (eCSSUnit_Percent == unit)
|
|
|
|
mMaxSize = cssValue.GetPercentValue();
|
|
|
|
else if (eCSSUnit_Null != unit) {
|
2014-10-25 10:29:00 +04:00
|
|
|
mMaxSize = float(CalcLength(presContext, mStyleContext, cssValue,
|
|
|
|
fontSizeInflation));
|
2008-03-14 07:05:43 +03:00
|
|
|
mFlags |= NS_MATHML_OPERATOR_MAXSIZE_ABSOLUTE;
|
2000-01-26 09:49:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-09-21 06:12:01 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t
|
2008-03-14 07:05:43 +03:00
|
|
|
GetStretchHint(nsOperatorFlags aFlags, nsPresentationData aPresentationData,
|
2014-01-14 18:39:50 +04:00
|
|
|
bool aIsVertical, const nsStyleFont* aStyleFont)
|
2008-03-14 07:05:43 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t stretchHint = NS_STRETCH_NONE;
|
2008-03-14 07:05:43 +03:00
|
|
|
// See if it is okay to stretch,
|
|
|
|
// starting from what the Operator Dictionary said
|
|
|
|
if (NS_MATHML_OPERATOR_IS_MUTABLE(aFlags)) {
|
|
|
|
// set the largeop or largeopOnly flags to suitably cover all the
|
|
|
|
// 8 possible cases depending on whether displaystyle, largeop,
|
|
|
|
// stretchy are true or false (see bug 69325).
|
|
|
|
// . largeopOnly is taken if largeop=true and stretchy=false
|
|
|
|
// . largeop is taken if largeop=true and stretchy=true
|
2014-01-14 18:39:50 +04:00
|
|
|
if (aStyleFont->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK &&
|
2008-03-14 07:05:43 +03:00
|
|
|
NS_MATHML_OPERATOR_IS_LARGEOP(aFlags)) {
|
|
|
|
stretchHint = NS_STRETCH_LARGEOP; // (largeopOnly, not mask!)
|
2010-08-20 07:44:07 +04:00
|
|
|
if (NS_MATHML_OPERATOR_IS_INTEGRAL(aFlags)) {
|
|
|
|
stretchHint |= NS_STRETCH_INTEGRAL;
|
|
|
|
}
|
2008-03-14 07:05:43 +03:00
|
|
|
if (NS_MATHML_OPERATOR_IS_STRETCHY(aFlags)) {
|
|
|
|
stretchHint |= NS_STRETCH_NEARER | NS_STRETCH_LARGER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(NS_MATHML_OPERATOR_IS_STRETCHY(aFlags)) {
|
|
|
|
if (aIsVertical) {
|
|
|
|
// TeX hint. Can impact some sloppy markups missing <mrow></mrow>
|
|
|
|
stretchHint = NS_STRETCH_NEARER;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stretchHint = NS_STRETCH_NORMAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// else if the stretchy and largeop attributes have been disabled,
|
|
|
|
// the operator is not mutable
|
|
|
|
}
|
|
|
|
return stretchHint;
|
|
|
|
}
|
|
|
|
|
1999-10-12 06:12:36 +04:00
|
|
|
// NOTE: aDesiredStretchSize is an IN/OUT parameter
|
|
|
|
// On input - it contains our current size
|
|
|
|
// On output - the same size or the new size that we want
|
|
|
|
NS_IMETHODIMP
|
2011-04-08 05:04:40 +04:00
|
|
|
nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
|
1999-11-17 03:49:37 +03:00
|
|
|
nsStretchDirection aStretchDirection,
|
2000-03-28 13:38:24 +04:00
|
|
|
nsBoundingMetrics& aContainerSize,
|
|
|
|
nsHTMLReflowMetrics& aDesiredStretchSize)
|
1999-10-12 06:12:36 +04:00
|
|
|
{
|
2002-02-07 07:38:08 +03:00
|
|
|
if (NS_MATHML_STRETCH_WAS_DONE(mPresentationData.flags)) {
|
2001-02-23 19:10:51 +03:00
|
|
|
NS_WARNING("it is wrong to fire stretch more than once on a frame");
|
1999-12-10 16:02:23 +03:00
|
|
|
return NS_OK;
|
1999-10-12 06:12:36 +04:00
|
|
|
}
|
2002-02-07 07:38:08 +03:00
|
|
|
mPresentationData.flags |= NS_MATHML_STRETCH_DONE;
|
1999-10-12 06:12:36 +04:00
|
|
|
|
2003-01-11 06:04:30 +03:00
|
|
|
nsIFrame* firstChild = mFrames.FirstChild();
|
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
// get the axis height;
|
2014-10-25 10:30:00 +04:00
|
|
|
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsFontMetrics> fm;
|
2014-10-25 10:29:00 +04:00
|
|
|
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
|
2014-10-25 10:30:00 +04:00
|
|
|
fontSizeInflation);
|
2003-01-11 06:04:30 +03:00
|
|
|
nscoord axisHeight, height;
|
2000-04-17 08:23:03 +04:00
|
|
|
GetAxisHeight(aRenderingContext, fm, axisHeight);
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2003-01-11 06:04:30 +03:00
|
|
|
// get the leading to be left at the top and the bottom of the stretched char
|
2011-04-08 05:04:40 +04:00
|
|
|
// this seems more reliable than using fm->GetLeading() on suspicious fonts
|
2003-01-11 06:04:30 +03:00
|
|
|
nscoord em;
|
|
|
|
GetEmHeight(fm, em);
|
|
|
|
nscoord leading = NSToCoordRound(0.2f * em);
|
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
// Operators that are stretchy, or those that are to be centered
|
2001-02-03 00:29:21 +03:00
|
|
|
// to cater for fonts that are not math-aware, are handled by the MathMLChar
|
2002-04-02 08:15:22 +04:00
|
|
|
// ('form' is reset if stretch fails -- i.e., we don't bother to stretch next time)
|
2011-09-29 10:19:26 +04:00
|
|
|
bool useMathMLChar = UseMathMLChar();
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2002-02-27 04:35:27 +03:00
|
|
|
nsBoundingMetrics charSize;
|
2008-02-27 13:45:36 +03:00
|
|
|
nsBoundingMetrics container = aDesiredStretchSize.mBoundingMetrics;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isVertical = false;
|
2000-01-26 09:49:38 +03:00
|
|
|
|
2009-09-28 00:32:54 +04:00
|
|
|
if (((aStretchDirection == NS_STRETCH_DIRECTION_VERTICAL) ||
|
|
|
|
(aStretchDirection == NS_STRETCH_DIRECTION_DEFAULT)) &&
|
|
|
|
(mEmbellishData.direction == NS_STRETCH_DIRECTION_VERTICAL)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
isVertical = true;
|
2009-09-28 00:32:54 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t stretchHint =
|
2014-01-14 18:39:50 +04:00
|
|
|
GetStretchHint(mFlags, mPresentationData, isVertical, StyleFont());
|
2000-05-08 11:31:05 +04:00
|
|
|
|
2009-09-28 00:32:54 +04:00
|
|
|
if (useMathMLChar) {
|
|
|
|
nsBoundingMetrics initialSize = aDesiredStretchSize.mBoundingMetrics;
|
2002-02-07 07:38:08 +03:00
|
|
|
|
2008-03-14 07:05:43 +03:00
|
|
|
if (stretchHint != NS_STRETCH_NONE) {
|
2000-01-26 09:49:38 +03:00
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
container = aContainerSize;
|
2000-01-26 09:49:38 +03:00
|
|
|
|
2001-02-02 12:40:53 +03:00
|
|
|
// some adjustments if the operator is symmetric and vertical
|
|
|
|
|
2001-04-09 02:32:29 +04:00
|
|
|
if (isVertical && NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) {
|
2000-03-28 13:38:24 +04:00
|
|
|
// we need to center about the axis
|
2013-01-15 16:22:03 +04:00
|
|
|
nscoord delta = std::max(container.ascent - axisHeight,
|
2000-03-28 13:38:24 +04:00
|
|
|
container.descent + axisHeight);
|
|
|
|
container.ascent = delta + axisHeight;
|
|
|
|
container.descent = delta - axisHeight;
|
|
|
|
|
|
|
|
// get ready in case we encounter user-desired min-max size
|
2013-01-15 16:22:03 +04:00
|
|
|
delta = std::max(initialSize.ascent - axisHeight,
|
2000-03-28 13:38:24 +04:00
|
|
|
initialSize.descent + axisHeight);
|
|
|
|
initialSize.ascent = delta + axisHeight;
|
|
|
|
initialSize.descent = delta - axisHeight;
|
2000-01-26 09:49:38 +03:00
|
|
|
}
|
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
// check for user-desired min-max size
|
|
|
|
|
2008-03-14 07:05:43 +03:00
|
|
|
if (mMaxSize != NS_MATHML_OPERATOR_SIZE_INFINITY && mMaxSize > 0.0f) {
|
2000-03-28 13:38:24 +04:00
|
|
|
// if we are here, there is a user defined maxsize ...
|
2006-09-08 11:32:45 +04:00
|
|
|
//XXX Set stretchHint = NS_STRETCH_NORMAL? to honor the maxsize as close as possible?
|
2008-03-14 07:05:43 +03:00
|
|
|
if (NS_MATHML_OPERATOR_MAXSIZE_IS_ABSOLUTE(mFlags)) {
|
2000-03-28 13:38:24 +04:00
|
|
|
// there is an explicit value like maxsize="20pt"
|
|
|
|
// try to maintain the aspect ratio of the char
|
|
|
|
float aspect = mMaxSize / float(initialSize.ascent + initialSize.descent);
|
|
|
|
container.ascent =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::min(container.ascent, nscoord(initialSize.ascent * aspect));
|
2000-03-28 13:38:24 +04:00
|
|
|
container.descent =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::min(container.descent, nscoord(initialSize.descent * aspect));
|
2000-03-28 13:38:24 +04:00
|
|
|
// below we use a type cast instead of a conversion to avoid a VC++ bug
|
|
|
|
// see http://support.microsoft.com/support/kb/articles/Q115/7/05.ASP
|
|
|
|
container.width =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::min(container.width, (nscoord)mMaxSize);
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
else { // multiplicative value
|
|
|
|
container.ascent =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::min(container.ascent, nscoord(initialSize.ascent * mMaxSize));
|
2000-03-28 13:38:24 +04:00
|
|
|
container.descent =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::min(container.descent, nscoord(initialSize.descent * mMaxSize));
|
2000-03-28 13:38:24 +04:00
|
|
|
container.width =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::min(container.width, nscoord(initialSize.width * mMaxSize));
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
2000-05-08 11:31:05 +04:00
|
|
|
|
2001-04-09 02:32:29 +04:00
|
|
|
if (isVertical && !NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) {
|
2000-05-08 11:31:05 +04:00
|
|
|
// re-adjust to align the char with the bottom of the initial container
|
|
|
|
height = container.ascent + container.descent;
|
2001-02-02 12:40:53 +03:00
|
|
|
container.descent = aContainerSize.descent;
|
2000-05-08 11:31:05 +04:00
|
|
|
container.ascent = height - container.descent;
|
|
|
|
}
|
2000-01-26 09:49:38 +03:00
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2008-03-14 07:05:43 +03:00
|
|
|
if (mMinSize > 0.0f) {
|
2000-03-28 13:38:24 +04:00
|
|
|
// if we are here, there is a user defined minsize ...
|
2006-09-08 11:32:45 +04:00
|
|
|
// always allow the char to stretch in its natural direction,
|
|
|
|
// even if it is different from the caller's direction
|
|
|
|
if (aStretchDirection != NS_STRETCH_DIRECTION_DEFAULT &&
|
|
|
|
aStretchDirection != mEmbellishData.direction) {
|
|
|
|
aStretchDirection = NS_STRETCH_DIRECTION_DEFAULT;
|
|
|
|
// but when we are not honoring the requested direction
|
|
|
|
// we should not use the caller's container size either
|
|
|
|
container = initialSize;
|
|
|
|
}
|
2008-03-14 07:05:43 +03:00
|
|
|
if (NS_MATHML_OPERATOR_MINSIZE_IS_ABSOLUTE(mFlags)) {
|
2000-03-28 13:38:24 +04:00
|
|
|
// there is an explicit value like minsize="20pt"
|
|
|
|
// try to maintain the aspect ratio of the char
|
|
|
|
float aspect = mMinSize / float(initialSize.ascent + initialSize.descent);
|
|
|
|
container.ascent =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(container.ascent, nscoord(initialSize.ascent * aspect));
|
2000-03-28 13:38:24 +04:00
|
|
|
container.descent =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(container.descent, nscoord(initialSize.descent * aspect));
|
2000-03-28 13:38:24 +04:00
|
|
|
container.width =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(container.width, (nscoord)mMinSize);
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
else { // multiplicative value
|
|
|
|
container.ascent =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(container.ascent, nscoord(initialSize.ascent * mMinSize));
|
2000-03-28 13:38:24 +04:00
|
|
|
container.descent =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(container.descent, nscoord(initialSize.descent * mMinSize));
|
2000-03-28 13:38:24 +04:00
|
|
|
container.width =
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(container.width, nscoord(initialSize.width * mMinSize));
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
2000-05-08 11:31:05 +04:00
|
|
|
|
2001-04-09 02:32:29 +04:00
|
|
|
if (isVertical && !NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags)) {
|
2000-05-08 11:31:05 +04:00
|
|
|
// re-adjust to align the char with the bottom of the initial container
|
|
|
|
height = container.ascent + container.descent;
|
2001-02-02 12:40:53 +03:00
|
|
|
container.descent = aContainerSize.descent;
|
2000-05-08 11:31:05 +04:00
|
|
|
container.ascent = height - container.descent;
|
|
|
|
}
|
2000-01-26 09:49:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-12 06:12:36 +04:00
|
|
|
// let the MathMLChar stretch itself...
|
2007-03-31 01:11:41 +04:00
|
|
|
nsresult res = mMathMLChar.Stretch(PresContext(), aRenderingContext,
|
2014-10-25 10:30:00 +04:00
|
|
|
fontSizeInflation,
|
2011-12-22 02:22:00 +04:00
|
|
|
aStretchDirection, container, charSize,
|
|
|
|
stretchHint,
|
2013-05-30 03:26:40 +04:00
|
|
|
StyleVisibility()->mDirection);
|
2000-07-25 04:08:15 +04:00
|
|
|
if (NS_FAILED(res)) {
|
2001-02-02 12:40:53 +03:00
|
|
|
// gracefully handle cases where stretching the char failed (i.e., GetBoundingMetrics failed)
|
2000-07-25 04:08:15 +04:00
|
|
|
// clear our 'form' to behave as if the operator wasn't in the dictionary
|
2001-02-02 12:40:53 +03:00
|
|
|
mFlags &= ~NS_MATHML_OPERATOR_FORM;
|
2011-10-17 18:59:28 +04:00
|
|
|
useMathMLChar = false;
|
2000-07-25 04:08:15 +04:00
|
|
|
}
|
|
|
|
}
|
1999-12-10 16:02:23 +03:00
|
|
|
|
2014-03-19 21:05:02 +04:00
|
|
|
// Place our children using the default method
|
|
|
|
// This will allow our child text frame to get its DidReflow()
|
|
|
|
nsresult rv = Place(aRenderingContext, true, aDesiredStretchSize);
|
|
|
|
if (NS_MATHML_HAS_ERROR(mPresentationData.flags) || NS_FAILED(rv)) {
|
|
|
|
// Make sure the child frames get their DidReflow() calls.
|
|
|
|
DidReflowChildren(mFrames.FirstChild());
|
2007-03-02 13:55:55 +03:00
|
|
|
}
|
2000-01-18 07:35:37 +03:00
|
|
|
|
2008-02-27 13:45:36 +03:00
|
|
|
if (useMathMLChar) {
|
|
|
|
// update our bounding metrics... it becomes that of our MathML char
|
|
|
|
mBoundingMetrics = charSize;
|
|
|
|
|
|
|
|
// if the returned direction is 'unsupported', the char didn't actually change.
|
|
|
|
// So we do the centering only if necessary
|
|
|
|
if (mMathMLChar.GetStretchDirection() != NS_STRETCH_DIRECTION_UNSUPPORTED ||
|
|
|
|
NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) {
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool largeopOnly =
|
2009-09-28 00:32:54 +04:00
|
|
|
(NS_STRETCH_LARGEOP & stretchHint) != 0 &&
|
|
|
|
(NS_STRETCH_VARIABLE_MASK & stretchHint) == 0;
|
|
|
|
|
2008-02-27 13:45:36 +03:00
|
|
|
if (isVertical || NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) {
|
|
|
|
// the desired size returned by mMathMLChar maybe different
|
|
|
|
// from the size of the container.
|
|
|
|
// the mMathMLChar.mRect.y calculation is subtle, watch out!!!
|
|
|
|
|
|
|
|
height = mBoundingMetrics.ascent + mBoundingMetrics.descent;
|
|
|
|
if (NS_MATHML_OPERATOR_IS_SYMMETRIC(mFlags) ||
|
|
|
|
NS_MATHML_OPERATOR_IS_CENTERED(mFlags)) {
|
|
|
|
// For symmetric and vertical operators, or for operators that are always
|
|
|
|
// centered ('+', '*', etc) we want to center about the axis of the container
|
|
|
|
mBoundingMetrics.descent = height/2 - axisHeight;
|
2009-09-28 00:32:54 +04:00
|
|
|
} else if (!largeopOnly) {
|
|
|
|
// Align the center of the char with the center of the container
|
|
|
|
mBoundingMetrics.descent = height/2 +
|
|
|
|
(container.ascent + container.descent)/2 - container.ascent;
|
|
|
|
} // else align the baselines
|
2008-02-27 13:45:36 +03:00
|
|
|
mBoundingMetrics.ascent = height - mBoundingMetrics.descent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-27 04:35:27 +03:00
|
|
|
// Fixup for the final height.
|
|
|
|
// On one hand, our stretchy height can sometimes be shorter than surrounding
|
|
|
|
// ASCII chars, e.g., arrow symbols have |mBoundingMetrics.ascent + leading|
|
|
|
|
// that is smaller than the ASCII's ascent, hence when painting the background
|
|
|
|
// later, it won't look uniform along the line.
|
|
|
|
// On the other hand, sometimes we may leave too much gap when our glyph happens
|
|
|
|
// to come from a font with tall glyphs. For example, since CMEX10 has very tall
|
|
|
|
// glyphs, its natural font metrics are large, even if we pick a small glyph
|
|
|
|
// whose size is comparable to the size of a normal ASCII glyph.
|
|
|
|
// So to avoid uneven spacing in either of these two cases, we use the height
|
|
|
|
// of the ASCII font as a reference and try to match it if possible.
|
2002-04-02 08:15:22 +04:00
|
|
|
|
|
|
|
// special case for accents... keep them short to improve mouse operations...
|
|
|
|
// an accent can only be the non-first child of <mover>, <munder>, <munderover>
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isAccent =
|
2002-04-02 08:15:22 +04:00
|
|
|
NS_MATHML_EMBELLISH_IS_ACCENT(mEmbellishData.flags);
|
|
|
|
if (isAccent) {
|
|
|
|
nsEmbellishData parentData;
|
2014-05-25 02:20:41 +04:00
|
|
|
GetEmbellishDataFrom(GetParent(), parentData);
|
2002-04-02 08:15:22 +04:00
|
|
|
isAccent =
|
|
|
|
(NS_MATHML_EMBELLISH_IS_ACCENTOVER(parentData.flags) ||
|
|
|
|
NS_MATHML_EMBELLISH_IS_ACCENTUNDER(parentData.flags)) &&
|
|
|
|
parentData.coreFrame != this;
|
|
|
|
}
|
2003-01-11 06:04:30 +03:00
|
|
|
if (isAccent && firstChild) {
|
|
|
|
// see bug 188467 for what is going on here
|
2014-06-11 13:45:31 +04:00
|
|
|
nscoord dy = aDesiredStretchSize.BlockStartAscent() -
|
|
|
|
(mBoundingMetrics.ascent + leading);
|
|
|
|
aDesiredStretchSize.SetBlockStartAscent(mBoundingMetrics.ascent + leading);
|
|
|
|
aDesiredStretchSize.Height() = aDesiredStretchSize.BlockStartAscent() +
|
|
|
|
mBoundingMetrics.descent;
|
2003-01-11 06:04:30 +03:00
|
|
|
|
2003-07-08 15:00:00 +04:00
|
|
|
firstChild->SetPosition(firstChild->GetPosition() - nsPoint(0, dy));
|
2002-04-02 08:15:22 +04:00
|
|
|
}
|
2003-01-11 06:04:30 +03:00
|
|
|
else if (useMathMLChar) {
|
2011-04-08 08:18:43 +04:00
|
|
|
nscoord ascent = fm->MaxAscent();
|
|
|
|
nscoord descent = fm->MaxDescent();
|
2014-06-11 13:45:31 +04:00
|
|
|
aDesiredStretchSize.SetBlockStartAscent(std::max(mBoundingMetrics.ascent + leading, ascent));
|
|
|
|
aDesiredStretchSize.Height() = aDesiredStretchSize.BlockStartAscent() +
|
2013-01-15 16:22:03 +04:00
|
|
|
std::max(mBoundingMetrics.descent + leading, descent);
|
2002-04-02 08:15:22 +04:00
|
|
|
}
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredStretchSize.Width() = mBoundingMetrics.width;
|
2002-02-27 04:35:27 +03:00
|
|
|
aDesiredStretchSize.mBoundingMetrics = mBoundingMetrics;
|
|
|
|
mReference.x = 0;
|
2014-06-11 13:45:31 +04:00
|
|
|
mReference.y = aDesiredStretchSize.BlockStartAscent();
|
2002-02-27 04:35:27 +03:00
|
|
|
// Place our mMathMLChar, its origin is in our coordinate system
|
|
|
|
if (useMathMLChar) {
|
2014-06-11 13:45:31 +04:00
|
|
|
nscoord dy = aDesiredStretchSize.BlockStartAscent() - mBoundingMetrics.ascent;
|
2002-02-27 04:35:27 +03:00
|
|
|
mMathMLChar.SetRect(nsRect(0, dy, charSize.width, charSize.ascent + charSize.descent));
|
|
|
|
}
|
|
|
|
|
1999-12-10 16:02:23 +03:00
|
|
|
// Before we leave... there is a last item in the check-list:
|
|
|
|
// If our parent is not embellished, it means we are the outermost embellished
|
|
|
|
// container and so we put the spacing, otherwise we don't include the spacing,
|
|
|
|
// the outermost embellished container will take care of it.
|
2000-03-28 13:38:24 +04:00
|
|
|
|
1999-12-10 16:02:23 +03:00
|
|
|
if (!NS_MATHML_OPERATOR_HAS_EMBELLISH_ANCESTOR(mFlags)) {
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
// Account the spacing if we are not an accent with explicit attributes
|
2011-12-22 02:21:59 +04:00
|
|
|
nscoord leadingSpace = mEmbellishData.leadingSpace;
|
|
|
|
if (isAccent && !NS_MATHML_OPERATOR_HAS_LSPACE_ATTR(mFlags)) {
|
|
|
|
leadingSpace = 0;
|
2002-04-02 08:15:22 +04:00
|
|
|
}
|
2011-12-22 02:21:59 +04:00
|
|
|
nscoord trailingSpace = mEmbellishData.trailingSpace;
|
|
|
|
if (isAccent && !NS_MATHML_OPERATOR_HAS_RSPACE_ATTR(mFlags)) {
|
|
|
|
trailingSpace = 0;
|
2002-04-02 08:15:22 +04:00
|
|
|
}
|
|
|
|
|
2011-12-22 02:21:59 +04:00
|
|
|
mBoundingMetrics.width += leadingSpace + trailingSpace;
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredStretchSize.Width() = mBoundingMetrics.width;
|
2002-01-05 04:15:04 +03:00
|
|
|
aDesiredStretchSize.mBoundingMetrics.width = mBoundingMetrics.width;
|
2000-01-20 01:36:23 +03:00
|
|
|
|
2013-05-30 03:26:40 +04:00
|
|
|
nscoord dx = (StyleVisibility()->mDirection ?
|
2011-12-22 02:21:59 +04:00
|
|
|
trailingSpace : leadingSpace);
|
|
|
|
if (dx) {
|
2002-03-22 07:49:33 +03:00
|
|
|
// adjust the offsets
|
2011-12-22 02:21:59 +04:00
|
|
|
mBoundingMetrics.leftBearing += dx;
|
|
|
|
mBoundingMetrics.rightBearing += dx;
|
|
|
|
aDesiredStretchSize.mBoundingMetrics.leftBearing += dx;
|
|
|
|
aDesiredStretchSize.mBoundingMetrics.rightBearing += dx;
|
2002-03-22 07:49:33 +03:00
|
|
|
|
|
|
|
if (useMathMLChar) {
|
2008-02-27 13:45:36 +03:00
|
|
|
nsRect rect;
|
2002-03-22 07:49:33 +03:00
|
|
|
mMathMLChar.GetRect(rect);
|
2011-12-22 02:21:59 +04:00
|
|
|
mMathMLChar.SetRect(nsRect(rect.x + dx, rect.y,
|
|
|
|
rect.width, rect.height));
|
2002-03-22 07:49:33 +03:00
|
|
|
}
|
|
|
|
else {
|
2003-01-11 06:04:30 +03:00
|
|
|
nsIFrame* childFrame = firstChild;
|
2002-03-22 07:49:33 +03:00
|
|
|
while (childFrame) {
|
2011-12-22 02:21:59 +04:00
|
|
|
childFrame->SetPosition(childFrame->GetPosition() +
|
|
|
|
nsPoint(dx, 0));
|
2003-07-08 15:00:00 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2002-03-22 07:49:33 +03:00
|
|
|
}
|
1999-10-12 06:12:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-03-22 07:49:33 +03:00
|
|
|
|
2008-02-27 13:45:36 +03:00
|
|
|
// Finished with these:
|
|
|
|
ClearSavedChildMetrics();
|
2007-12-29 02:04:19 +03:00
|
|
|
// Set our overflow area
|
|
|
|
GatherAndStoreOverflow(&aDesiredStretchSize);
|
|
|
|
|
2008-01-14 05:10:29 +03:00
|
|
|
// There used to be code here to change the height of the child frame to
|
|
|
|
// change the caret height, but the text frame that manages the caret is now
|
|
|
|
// not a direct child but wrapped in a block frame. See also bug 412033.
|
2002-04-02 08:15:22 +04:00
|
|
|
|
1999-10-12 06:12:36 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-10 16:02:23 +03:00
|
|
|
|
2002-04-02 08:15:22 +04:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLmoFrame::InheritAutomaticData(nsIFrame* aParent)
|
2002-04-02 08:15:22 +04:00
|
|
|
{
|
|
|
|
// retain our native direction, it only changes if our text content changes
|
|
|
|
nsStretchDirection direction = mEmbellishData.direction;
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLTokenFrame::InheritAutomaticData(aParent);
|
2013-12-02 20:50:10 +04:00
|
|
|
ProcessTextData();
|
2002-04-02 08:15:22 +04:00
|
|
|
mEmbellishData.direction = direction;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-02-07 07:38:08 +03:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:57:50 +03:00
|
|
|
nsMathMLmoFrame::TransmitAutomaticData()
|
2002-02-07 07:38:08 +03:00
|
|
|
{
|
|
|
|
// this will cause us to re-sync our flags from scratch
|
2002-04-02 08:15:22 +04:00
|
|
|
// but our returned 'form' is still not final (bug 133429), it will
|
|
|
|
// be recomputed to its final value during the next call in Reflow()
|
2012-07-30 18:20:58 +04:00
|
|
|
mEmbellishData.coreFrame = nullptr;
|
2005-02-07 04:57:50 +03:00
|
|
|
ProcessOperatorData();
|
2002-02-07 07:38:08 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2013-12-02 20:50:10 +04:00
|
|
|
nsMathMLmoFrame::SetInitialChildList(ChildListID aListID,
|
|
|
|
nsFrameList& aChildList)
|
|
|
|
{
|
|
|
|
// First, let the parent class do its work
|
2014-05-28 23:36:58 +04:00
|
|
|
nsMathMLTokenFrame::SetInitialChildList(aListID, aChildList);
|
2013-12-02 20:50:10 +04:00
|
|
|
ProcessTextData();
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsMathMLmoFrame::Reflow(nsPresContext* aPresContext,
|
2000-01-07 17:49:46 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2002-02-07 07:38:08 +03:00
|
|
|
// certain values use units that depend on our style context, so
|
|
|
|
// it is safer to just process the whole lot here
|
2005-02-07 04:57:50 +03:00
|
|
|
ProcessOperatorData();
|
2005-09-07 03:47:01 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
nsMathMLTokenFrame::Reflow(aPresContext, aDesiredSize,
|
|
|
|
aReflowState, aStatus);
|
2000-01-07 17:49:46 +03:00
|
|
|
}
|
2000-03-28 13:38:24 +04:00
|
|
|
|
2014-12-05 04:31:00 +03:00
|
|
|
nsresult
|
|
|
|
nsMathMLmoFrame::Place(nsRenderingContext& aRenderingContext,
|
|
|
|
bool aPlaceOrigin,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
|
|
|
{
|
|
|
|
nsresult rv = nsMathMLTokenFrame::Place(aRenderingContext, aPlaceOrigin,
|
|
|
|
aDesiredSize);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Special behaviour for largeops.
|
|
|
|
In MathML "stretchy" and displaystyle "largeop" are different notions,
|
|
|
|
even if we use the same technique to draw them (picking size variants).
|
|
|
|
So largeop display operators should be considered "non-stretchy" and
|
|
|
|
thus their sizes should be taken into account for the stretch size of
|
|
|
|
other elements.
|
|
|
|
|
|
|
|
This is a preliminary stretch - exact sizing/placement is handled by the
|
|
|
|
Stretch() method.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!aPlaceOrigin &&
|
|
|
|
StyleFont()->mMathDisplay == NS_MATHML_DISPLAYSTYLE_BLOCK &&
|
|
|
|
NS_MATHML_OPERATOR_IS_LARGEOP(mFlags) && UseMathMLChar()) {
|
|
|
|
nsBoundingMetrics newMetrics;
|
|
|
|
rv = mMathMLChar.Stretch(PresContext(), aRenderingContext,
|
|
|
|
nsLayoutUtils::FontSizeInflationFor(this),
|
|
|
|
NS_STRETCH_DIRECTION_VERTICAL,
|
|
|
|
aDesiredSize.mBoundingMetrics, newMetrics,
|
|
|
|
NS_STRETCH_LARGEOP, StyleVisibility()->mDirection);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Just use the initial size
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
aDesiredSize.mBoundingMetrics = newMetrics;
|
|
|
|
/* Treat the ascent/descent values calculated in the TokenFrame place
|
|
|
|
calculations as the minimum for aDesiredSize calculations, rather
|
|
|
|
than fetching them from font metrics again.
|
|
|
|
*/
|
|
|
|
aDesiredSize.SetBlockStartAscent(std::max(mBoundingMetrics.ascent,
|
|
|
|
newMetrics.ascent));
|
|
|
|
aDesiredSize.Height() = aDesiredSize.BlockStartAscent() +
|
|
|
|
std::max(mBoundingMetrics.descent,
|
|
|
|
newMetrics.descent);
|
|
|
|
aDesiredSize.Width() = newMetrics.width;
|
|
|
|
mBoundingMetrics = newMetrics;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* virtual */ void
|
2014-07-24 21:03:26 +04:00
|
|
|
nsMathMLmoFrame::MarkIntrinsicISizesDirty()
|
2002-02-07 07:38:08 +03:00
|
|
|
{
|
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
|
|
|
// if we get this, it may mean that something changed in the text
|
|
|
|
// content. So blow away everything an re-build the automatic data
|
|
|
|
// from the parent of our outermost embellished container (we ensure
|
|
|
|
// that we are the core, not just a sibling of the core)
|
2002-02-07 07:38:08 +03:00
|
|
|
|
2008-01-27 05:49:47 +03:00
|
|
|
ProcessTextData();
|
2002-02-07 07:38:08 +03:00
|
|
|
|
|
|
|
nsIFrame* target = this;
|
|
|
|
nsEmbellishData embellishData;
|
|
|
|
do {
|
2003-07-08 15:00:00 +04:00
|
|
|
target = target->GetParent();
|
2002-02-07 07:38:08 +03:00
|
|
|
GetEmbellishDataFrom(target, embellishData);
|
|
|
|
} while (embellishData.coreFrame == this);
|
|
|
|
|
|
|
|
// we have automatic data to update in the children of the target frame
|
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
|
|
|
// XXXldb This should really be marking dirty rather than rebuilding
|
|
|
|
// so that we don't rebuild multiple times for the same change.
|
|
|
|
RebuildAutomaticDataForChildren(target);
|
|
|
|
|
2014-07-24 21:03:26 +04:00
|
|
|
nsMathMLContainerFrame::MarkIntrinsicISizesDirty();
|
2002-02-07 07:38:08 +03:00
|
|
|
}
|
|
|
|
|
2013-11-25 18:20:20 +04:00
|
|
|
/* virtual */ void
|
2015-03-05 07:22:26 +03:00
|
|
|
nsMathMLmoFrame::GetIntrinsicISizeMetrics(nsRenderingContext* aRenderingContext,
|
2015-03-05 04:46:40 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize)
|
2008-02-27 13:47:43 +03:00
|
|
|
{
|
|
|
|
ProcessOperatorData();
|
2008-03-14 07:05:43 +03:00
|
|
|
if (UseMathMLChar()) {
|
2014-01-14 18:39:50 +04:00
|
|
|
uint32_t stretchHint = GetStretchHint(mFlags, mPresentationData, true,
|
|
|
|
StyleFont());
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = mMathMLChar.
|
2008-03-14 07:05:43 +03:00
|
|
|
GetMaxWidth(PresContext(), *aRenderingContext,
|
2014-10-25 10:30:00 +04:00
|
|
|
nsLayoutUtils::FontSizeInflationFor(this),
|
2015-03-05 04:46:40 +03:00
|
|
|
stretchHint);
|
2008-03-14 07:05:43 +03:00
|
|
|
}
|
|
|
|
else {
|
2014-07-24 21:03:26 +04:00
|
|
|
nsMathMLTokenFrame::GetIntrinsicISizeMetrics(aRenderingContext,
|
2013-11-25 18:20:20 +04:00
|
|
|
aDesiredSize);
|
2008-03-14 07:05:43 +03:00
|
|
|
}
|
2008-02-27 13:47:43 +03:00
|
|
|
|
2011-12-22 02:21:59 +04:00
|
|
|
// leadingSpace and trailingSpace are actually applied to the outermost
|
2008-02-27 13:47:43 +03:00
|
|
|
// embellished container but for determining total intrinsic width it should
|
|
|
|
// be safe to include it for the core here instead.
|
2013-11-25 18:20:20 +04:00
|
|
|
bool isRTL = StyleVisibility()->mDirection;
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() +=
|
2013-11-25 18:20:20 +04:00
|
|
|
mEmbellishData.leadingSpace + mEmbellishData.trailingSpace;
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.mBoundingMetrics.width = aDesiredSize.Width();
|
2013-11-25 18:20:20 +04:00
|
|
|
if (isRTL) {
|
|
|
|
aDesiredSize.mBoundingMetrics.leftBearing += mEmbellishData.trailingSpace;
|
|
|
|
aDesiredSize.mBoundingMetrics.rightBearing += mEmbellishData.trailingSpace;
|
|
|
|
} else {
|
|
|
|
aDesiredSize.mBoundingMetrics.leftBearing += mEmbellishData.leadingSpace;
|
|
|
|
aDesiredSize.mBoundingMetrics.rightBearing += mEmbellishData.leadingSpace;
|
|
|
|
}
|
2008-02-27 13:47:43 +03:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLmoFrame::AttributeChanged(int32_t aNameSpaceID,
|
2002-02-08 03:57:39 +03:00
|
|
|
nsIAtom* aAttribute,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aModType)
|
2002-02-08 03:57:39 +03:00
|
|
|
{
|
|
|
|
// check if this is an attribute that can affect the embellished hierarchy
|
|
|
|
// in a significant way and re-layout the entire hierarchy.
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::accent_ == aAttribute ||
|
|
|
|
nsGkAtoms::movablelimits_ == aAttribute) {
|
2002-02-08 03:57:39 +03:00
|
|
|
|
|
|
|
// set the target as the parent of our outermost embellished container
|
|
|
|
// (we ensure that we are the core, not just a sibling of the core)
|
|
|
|
nsIFrame* target = this;
|
|
|
|
nsEmbellishData embellishData;
|
|
|
|
do {
|
2003-07-08 15:00:00 +04:00
|
|
|
target = target->GetParent();
|
2002-02-08 03:57:39 +03:00
|
|
|
GetEmbellishDataFrom(target, embellishData);
|
|
|
|
} while (embellishData.coreFrame == this);
|
|
|
|
|
|
|
|
// we have automatic data to update in the children of the target frame
|
2009-02-11 01:05:27 +03:00
|
|
|
return ReLayoutChildren(target);
|
2002-02-08 03:57:39 +03:00
|
|
|
}
|
|
|
|
|
2002-08-17 01:36:31 +04:00
|
|
|
return nsMathMLTokenFrame::
|
2005-09-07 20:49:21 +04:00
|
|
|
AttributeChanged(aNameSpaceID, aAttribute, aModType);
|
2002-02-08 03:57:39 +03:00
|
|
|
}
|
|
|
|
|
2000-03-28 13:38:24 +04:00
|
|
|
// ----------------------
|
2009-08-17 01:53:42 +04:00
|
|
|
// No need to track the style context given to our MathML char.
|
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*
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLmoFrame::GetAdditionalStyleContext(int32_t aIndex) const
|
2000-03-28 13:38:24 +04:00
|
|
|
{
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_MATHML_CHAR_STYLE_CONTEXT_INDEX:
|
2003-02-22 03:32:13 +03:00
|
|
|
return mMathMLChar.GetStyleContext();
|
2000-03-28 13:38:24 +04:00
|
|
|
default:
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2000-03-28 13:38:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsMathMLmoFrame::SetAdditionalStyleContext(int32_t aIndex,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext)
|
2000-03-28 13:38:24 +04:00
|
|
|
{
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_MATHML_CHAR_STYLE_CONTEXT_INDEX:
|
|
|
|
mMathMLChar.SetStyleContext(aStyleContext);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|