2007-06-11 23:10:23 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsMathMLmfracFrame_h___
|
|
|
|
#define nsMathMLmfracFrame_h___
|
|
|
|
|
2012-09-14 09:10:08 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsMathMLContainerFrame.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// <mfrac> -- form a fraction from two subexpressions
|
|
|
|
//
|
|
|
|
|
|
|
|
/*
|
|
|
|
The MathML REC describes:
|
|
|
|
|
|
|
|
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.
|
|
|
|
The syntax for <mfrac> is:
|
|
|
|
<mfrac> numerator denominator </mfrac>
|
|
|
|
|
|
|
|
Attributes of <mfrac>:
|
|
|
|
Name values default
|
|
|
|
linethickness number [ v-unit ] | thin | medium | thick 1
|
|
|
|
|
|
|
|
E.g.,
|
|
|
|
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
|
|
|
|
nested fractions.
|
|
|
|
|
|
|
|
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
|
|
|
|
up to the renderer).
|
|
|
|
|
|
|
|
The <mfrac> element sets displaystyle to "false", or if it was already
|
|
|
|
false increments scriptlevel by 1, within numerator and denominator.
|
|
|
|
These attributes are inherited by every element from its rendering
|
|
|
|
environment, but can be set explicitly only on the <mstyle>
|
|
|
|
element.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsMathMLmfracFrame : public nsMathMLContainerFrame {
|
|
|
|
public:
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
friend nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual eMathMLFrameType GetMathMLFrameType() override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-10-07 02:31:45 -07:00
|
|
|
virtual nsresult
|
2011-04-07 18:04:40 -07:00
|
|
|
MeasureForWidth(nsRenderingContext& aRenderingContext,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize) override;
|
2008-03-13 22:02:49 -07:00
|
|
|
|
2008-03-17 21:52:48 -07:00
|
|
|
virtual nsresult
|
2011-04-07 18:04:40 -07:00
|
|
|
Place(nsRenderingContext& aRenderingContext,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aPlaceOrigin,
|
2015-03-21 09:28:04 -07:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-02-14 03:12:27 -08:00
|
|
|
virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
2015-03-21 09:28:04 -07:00
|
|
|
const nsDisplayListSet& aLists) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMETHOD
|
2015-03-21 09:28:04 -07:00
|
|
|
TransmitAutomaticData() override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// override the base method so that we can deal with the fraction line
|
|
|
|
virtual nscoord
|
2015-03-21 09:28:04 -07:00
|
|
|
FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize) override;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// helper to translate the thickness attribute into a usable form
|
|
|
|
static nscoord
|
|
|
|
CalcLineThickness(nsPresContext* aPresContext,
|
|
|
|
nsStyleContext* aStyleContext,
|
|
|
|
nsString& aThicknessAttribute,
|
|
|
|
nscoord onePixel,
|
2014-10-24 23:29:00 -07:00
|
|
|
nscoord aDefaultRuleThickness,
|
|
|
|
float aFontSizeInflation);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-01-15 06:49:00 -08:00
|
|
|
uint8_t
|
2015-03-21 09:28:04 -07:00
|
|
|
ScriptIncrement(nsIFrame* aFrame) override;
|
2014-01-15 06:49:00 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
protected:
|
2014-08-31 20:36:37 -07:00
|
|
|
explicit nsMathMLmfracFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~nsMathMLmfracFrame();
|
|
|
|
|
2011-04-07 18:04:40 -07:00
|
|
|
nsresult PlaceInternal(nsRenderingContext& aRenderingContext,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aPlaceOrigin,
|
2009-10-07 02:31:45 -07:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aWidthOnly);
|
2009-10-07 02:31:45 -07:00
|
|
|
|
|
|
|
// Display a slash
|
2013-02-14 03:12:27 -08:00
|
|
|
void DisplaySlash(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsIFrame* aFrame, const nsRect& aRect,
|
|
|
|
nscoord aThickness,
|
|
|
|
const nsDisplayListSet& aLists);
|
2009-10-07 02:31:45 -07:00
|
|
|
|
|
|
|
nsRect mLineRect;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsMathMLChar* mSlashChar;
|
2009-10-07 02:31:45 -07:00
|
|
|
nscoord mLineThickness;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mIsBevelled;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsMathMLmfracFrame_h___ */
|