michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsMathMLmfracFrame_h___ michael@0: #define nsMathMLmfracFrame_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsMathMLContainerFrame.h" michael@0: michael@0: // michael@0: // -- form a fraction from two subexpressions michael@0: // michael@0: michael@0: /* michael@0: The MathML REC describes: michael@0: michael@0: The element is used for fractions. It can also be used to mark up michael@0: fraction-like objects such as binomial coefficients and Legendre symbols. michael@0: The syntax for is: michael@0: numerator denominator michael@0: michael@0: Attributes of : michael@0: Name values default michael@0: linethickness number [ v-unit ] | thin | medium | thick 1 michael@0: michael@0: E.g., michael@0: linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS michael@0: (DEFAULT_THICKNESS is not specified by MathML, see below.) michael@0: michael@0: The linethickness attribute indicates the thickness of the horizontal michael@0: "fraction bar", or "rule", typically used to render fractions. A fraction michael@0: with linethickness="0" renders without the bar, and might be used within michael@0: binomial coefficients. A linethickness greater than one might be used with michael@0: nested fractions. michael@0: michael@0: In general, the value of linethickness can be a number, as a multiplier michael@0: of the default thickness of the fraction bar (the default thickness is michael@0: not specified by MathML), or a number with a unit of vertical length (see michael@0: Section 2.3.3), or one of the keywords medium (same as 1), thin (thinner michael@0: than 1, otherwise up to the renderer), or thick (thicker than 1, otherwise michael@0: up to the renderer). michael@0: michael@0: The element sets displaystyle to "false", or if it was already michael@0: false increments scriptlevel by 1, within numerator and denominator. michael@0: These attributes are inherited by every element from its rendering michael@0: environment, but can be set explicitly only on the michael@0: element. michael@0: */ michael@0: michael@0: class nsMathMLmfracFrame : public nsMathMLContainerFrame { michael@0: public: michael@0: NS_DECL_FRAMEARENA_HELPERS michael@0: michael@0: friend nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); michael@0: michael@0: virtual eMathMLFrameType GetMathMLFrameType() MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: MeasureForWidth(nsRenderingContext& aRenderingContext, michael@0: nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; michael@0: michael@0: virtual nsresult michael@0: Place(nsRenderingContext& aRenderingContext, michael@0: bool aPlaceOrigin, michael@0: nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; michael@0: michael@0: virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) MOZ_OVERRIDE; michael@0: michael@0: NS_IMETHOD michael@0: TransmitAutomaticData() MOZ_OVERRIDE; michael@0: michael@0: // override the base method so that we can deal with the fraction line michael@0: virtual nscoord michael@0: FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; michael@0: michael@0: // helper to translate the thickness attribute into a usable form michael@0: static nscoord michael@0: CalcLineThickness(nsPresContext* aPresContext, michael@0: nsStyleContext* aStyleContext, michael@0: nsString& aThicknessAttribute, michael@0: nscoord onePixel, michael@0: nscoord aDefaultRuleThickness); michael@0: michael@0: uint8_t michael@0: ScriptIncrement(nsIFrame* aFrame) MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: nsMathMLmfracFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {} michael@0: virtual ~nsMathMLmfracFrame(); michael@0: michael@0: nsresult PlaceInternal(nsRenderingContext& aRenderingContext, michael@0: bool aPlaceOrigin, michael@0: nsHTMLReflowMetrics& aDesiredSize, michael@0: bool aWidthOnly); michael@0: michael@0: // Display a slash michael@0: void DisplaySlash(nsDisplayListBuilder* aBuilder, michael@0: nsIFrame* aFrame, const nsRect& aRect, michael@0: nscoord aThickness, michael@0: const nsDisplayListSet& aLists); michael@0: michael@0: nsRect mLineRect; michael@0: nsMathMLChar* mSlashChar; michael@0: nscoord mLineThickness; michael@0: bool mIsBevelled; michael@0: }; michael@0: michael@0: #endif /* nsMathMLmfracFrame_h___ */