2017-10-27 17:33:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
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
|
|
|
|
|
|
|
#ifndef nsMathMLmfracFrame_h___
|
|
|
|
#define nsMathMLmfracFrame_h___
|
|
|
|
|
2012-09-14 16:10:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
1999-09-21 02:12:01 +00:00
|
|
|
#include "nsMathMLContainerFrame.h"
|
|
|
|
|
|
|
|
//
|
2017-07-06 12:00:35 +00:00
|
|
|
// <mfrac> -- form a fraction from two subexpressions
|
1999-09-21 02:12:01 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
/*
|
|
|
|
The MathML REC describes:
|
|
|
|
|
2017-07-06 12:00:35 +00:00
|
|
|
The <mfrac> element is used for fractions. It can also be used to mark up
|
|
|
|
fraction-like objects such as binomial coefficients and Legendre symbols.
|
1999-09-21 02:12:01 +00:00
|
|
|
The syntax for <mfrac> is:
|
|
|
|
<mfrac> numerator denominator </mfrac>
|
|
|
|
|
|
|
|
Attributes of <mfrac>:
|
2017-07-06 12:00:35 +00:00
|
|
|
Name values default
|
|
|
|
linethickness number [ v-unit ] | thin | medium | thick 1
|
1999-09-21 02:12:01 +00:00
|
|
|
|
2017-07-06 12:00:35 +00:00
|
|
|
E.g.,
|
1999-09-21 02:12:01 +00:00
|
|
|
linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS
|
|
|
|
(DEFAULT_THICKNESS is not specified by MathML, see below.)
|
|
|
|
|
|
|
|
The linethickness attribute indicates the thickness of the horizontal
|
|
|
|
"fraction bar", or "rule", typically used to render fractions. A fraction
|
|
|
|
with linethickness="0" renders without the bar, and might be used within
|
|
|
|
binomial coefficients. A linethickness greater than one might be used with
|
2017-07-06 12:00:35 +00:00
|
|
|
nested fractions.
|
1999-09-21 02:12:01 +00:00
|
|
|
|
|
|
|
In general, the value of linethickness can be a number, as a multiplier
|
|
|
|
of the default thickness of the fraction bar (the default thickness is
|
|
|
|
not specified by MathML), or a number with a unit of vertical length (see
|
|
|
|
Section 2.3.3), or one of the keywords medium (same as 1), thin (thinner
|
|
|
|
than 1, otherwise up to the renderer), or thick (thicker than 1, otherwise
|
2017-07-06 12:00:35 +00:00
|
|
|
up to the renderer).
|
1999-09-21 02:12:01 +00:00
|
|
|
|
|
|
|
The <mfrac> element sets displaystyle to "false", or if it was already
|
|
|
|
false increments scriptlevel by 1, within numerator and denominator.
|
2017-07-06 12:00:35 +00:00
|
|
|
These attributes are inherited by every element from its rendering
|
|
|
|
environment, but can be set explicitly only on the <mstyle>
|
|
|
|
element.
|
1999-09-21 02:12:01 +00:00
|
|
|
*/
|
|
|
|
|
2018-09-06 01:23:14 +00:00
|
|
|
class nsMathMLmfracFrame final : public nsMathMLContainerFrame {
|
1999-09-21 02:12:01 +00:00
|
|
|
public:
|
2017-05-26 10:11:11 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsMathMLmfracFrame)
|
2009-09-12 16:49:24 +00:00
|
|
|
|
2018-03-22 18:20:41 +00:00
|
|
|
friend nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell,
|
|
|
|
ComputedStyle* aStyle);
|
1999-09-21 02:12:01 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual eMathMLFrameType GetMathMLFrameType() override;
|
2005-09-06 23:47:01 +00:00
|
|
|
|
2015-12-15 21:56:41 +00:00
|
|
|
virtual nsresult MeasureForWidth(DrawTarget* aDrawTarget,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize) override;
|
2008-03-14 05:02:49 +00:00
|
|
|
|
2015-12-15 21:56:41 +00:00
|
|
|
virtual nsresult Place(DrawTarget* aDrawTarget, bool aPlaceOrigin,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize) override;
|
1999-09-21 02:12:01 +00:00
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsDisplayListSet& aLists) override;
|
1999-09-21 02:12:01 +00:00
|
|
|
|
2016-03-31 01:59:00 +00:00
|
|
|
virtual nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
|
|
|
|
int32_t aModType) override;
|
|
|
|
|
2002-02-01 15:10:50 +00:00
|
|
|
NS_IMETHOD
|
2015-03-21 16:28:04 +00:00
|
|
|
TransmitAutomaticData() override;
|
2002-02-01 15:10:50 +00:00
|
|
|
|
2005-09-16 00:39:27 +00:00
|
|
|
// override the base method so that we can deal with the fraction line
|
2016-07-21 10:36:38 +00:00
|
|
|
virtual nscoord FixInterFrameSpacing(ReflowOutput& aDesiredSize) override;
|
2005-09-16 00:39:27 +00:00
|
|
|
|
2000-03-28 09:38:24 +00:00
|
|
|
// helper to translate the thickness attribute into a usable form
|
2004-07-31 23:15:21 +00:00
|
|
|
static nscoord CalcLineThickness(nsPresContext* aPresContext,
|
2018-03-22 18:20:41 +00:00
|
|
|
ComputedStyle* aComputedStyle,
|
2000-03-28 09:38:24 +00:00
|
|
|
nsString& aThicknessAttribute,
|
|
|
|
nscoord onePixel,
|
2014-10-25 06:29:00 +00:00
|
|
|
nscoord aDefaultRuleThickness,
|
|
|
|
float aFontSizeInflation);
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
uint8_t ScriptIncrement(nsIFrame* aFrame) override;
|
2018-11-30 10:46:48 +00:00
|
|
|
|
1999-09-21 02:12:01 +00:00
|
|
|
protected:
|
2018-03-22 18:20:41 +00:00
|
|
|
explicit nsMathMLmfracFrame(ComputedStyle* aStyle)
|
|
|
|
: nsMathMLContainerFrame(aStyle, kClassID),
|
2016-12-01 08:06:50 +00:00
|
|
|
mLineRect(),
|
|
|
|
mSlashChar(nullptr),
|
|
|
|
mLineThickness(0),
|
|
|
|
mIsBevelled(false) {}
|
1999-09-21 02:12:01 +00:00
|
|
|
virtual ~nsMathMLmfracFrame();
|
2015-12-15 21:56:41 +00:00
|
|
|
|
|
|
|
nsresult PlaceInternal(DrawTarget* aDrawTarget, bool aPlaceOrigin,
|
2016-07-21 10:36:38 +00:00
|
|
|
ReflowOutput& aDesiredSize, bool aWidthOnly);
|
2009-10-07 09:31:45 +00:00
|
|
|
|
|
|
|
// Display a slash
|
2013-02-14 11:12:27 +00:00
|
|
|
void DisplaySlash(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
|
|
|
|
const nsRect& aRect, nscoord aThickness,
|
|
|
|
const nsDisplayListSet& aLists);
|
2009-10-07 09:31:45 +00:00
|
|
|
|
|
|
|
nsRect mLineRect;
|
2002-01-05 01:15:04 +00:00
|
|
|
nsMathMLChar* mSlashChar;
|
2009-10-07 09:31:45 +00:00
|
|
|
nscoord mLineThickness;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mIsBevelled;
|
1999-09-21 02:12:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsMathMLmfracFrame_h___ */
|