Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsMathMLmfracFrame_h___ |
michael@0 | 7 | #define nsMathMLmfracFrame_h___ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/Attributes.h" |
michael@0 | 10 | #include "nsMathMLContainerFrame.h" |
michael@0 | 11 | |
michael@0 | 12 | // |
michael@0 | 13 | // <mfrac> -- form a fraction from two subexpressions |
michael@0 | 14 | // |
michael@0 | 15 | |
michael@0 | 16 | /* |
michael@0 | 17 | The MathML REC describes: |
michael@0 | 18 | |
michael@0 | 19 | The <mfrac> element is used for fractions. It can also be used to mark up |
michael@0 | 20 | fraction-like objects such as binomial coefficients and Legendre symbols. |
michael@0 | 21 | The syntax for <mfrac> is: |
michael@0 | 22 | <mfrac> numerator denominator </mfrac> |
michael@0 | 23 | |
michael@0 | 24 | Attributes of <mfrac>: |
michael@0 | 25 | Name values default |
michael@0 | 26 | linethickness number [ v-unit ] | thin | medium | thick 1 |
michael@0 | 27 | |
michael@0 | 28 | E.g., |
michael@0 | 29 | linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS |
michael@0 | 30 | (DEFAULT_THICKNESS is not specified by MathML, see below.) |
michael@0 | 31 | |
michael@0 | 32 | The linethickness attribute indicates the thickness of the horizontal |
michael@0 | 33 | "fraction bar", or "rule", typically used to render fractions. A fraction |
michael@0 | 34 | with linethickness="0" renders without the bar, and might be used within |
michael@0 | 35 | binomial coefficients. A linethickness greater than one might be used with |
michael@0 | 36 | nested fractions. |
michael@0 | 37 | |
michael@0 | 38 | In general, the value of linethickness can be a number, as a multiplier |
michael@0 | 39 | of the default thickness of the fraction bar (the default thickness is |
michael@0 | 40 | not specified by MathML), or a number with a unit of vertical length (see |
michael@0 | 41 | Section 2.3.3), or one of the keywords medium (same as 1), thin (thinner |
michael@0 | 42 | than 1, otherwise up to the renderer), or thick (thicker than 1, otherwise |
michael@0 | 43 | up to the renderer). |
michael@0 | 44 | |
michael@0 | 45 | The <mfrac> element sets displaystyle to "false", or if it was already |
michael@0 | 46 | false increments scriptlevel by 1, within numerator and denominator. |
michael@0 | 47 | These attributes are inherited by every element from its rendering |
michael@0 | 48 | environment, but can be set explicitly only on the <mstyle> |
michael@0 | 49 | element. |
michael@0 | 50 | */ |
michael@0 | 51 | |
michael@0 | 52 | class nsMathMLmfracFrame : public nsMathMLContainerFrame { |
michael@0 | 53 | public: |
michael@0 | 54 | NS_DECL_FRAMEARENA_HELPERS |
michael@0 | 55 | |
michael@0 | 56 | friend nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); |
michael@0 | 57 | |
michael@0 | 58 | virtual eMathMLFrameType GetMathMLFrameType() MOZ_OVERRIDE; |
michael@0 | 59 | |
michael@0 | 60 | virtual nsresult |
michael@0 | 61 | MeasureForWidth(nsRenderingContext& aRenderingContext, |
michael@0 | 62 | nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
michael@0 | 63 | |
michael@0 | 64 | virtual nsresult |
michael@0 | 65 | Place(nsRenderingContext& aRenderingContext, |
michael@0 | 66 | bool aPlaceOrigin, |
michael@0 | 67 | nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
michael@0 | 68 | |
michael@0 | 69 | virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
michael@0 | 70 | const nsRect& aDirtyRect, |
michael@0 | 71 | const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
michael@0 | 72 | |
michael@0 | 73 | NS_IMETHOD |
michael@0 | 74 | TransmitAutomaticData() MOZ_OVERRIDE; |
michael@0 | 75 | |
michael@0 | 76 | // override the base method so that we can deal with the fraction line |
michael@0 | 77 | virtual nscoord |
michael@0 | 78 | FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE; |
michael@0 | 79 | |
michael@0 | 80 | // helper to translate the thickness attribute into a usable form |
michael@0 | 81 | static nscoord |
michael@0 | 82 | CalcLineThickness(nsPresContext* aPresContext, |
michael@0 | 83 | nsStyleContext* aStyleContext, |
michael@0 | 84 | nsString& aThicknessAttribute, |
michael@0 | 85 | nscoord onePixel, |
michael@0 | 86 | nscoord aDefaultRuleThickness); |
michael@0 | 87 | |
michael@0 | 88 | uint8_t |
michael@0 | 89 | ScriptIncrement(nsIFrame* aFrame) MOZ_OVERRIDE; |
michael@0 | 90 | |
michael@0 | 91 | protected: |
michael@0 | 92 | nsMathMLmfracFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {} |
michael@0 | 93 | virtual ~nsMathMLmfracFrame(); |
michael@0 | 94 | |
michael@0 | 95 | nsresult PlaceInternal(nsRenderingContext& aRenderingContext, |
michael@0 | 96 | bool aPlaceOrigin, |
michael@0 | 97 | nsHTMLReflowMetrics& aDesiredSize, |
michael@0 | 98 | bool aWidthOnly); |
michael@0 | 99 | |
michael@0 | 100 | // Display a slash |
michael@0 | 101 | void DisplaySlash(nsDisplayListBuilder* aBuilder, |
michael@0 | 102 | nsIFrame* aFrame, const nsRect& aRect, |
michael@0 | 103 | nscoord aThickness, |
michael@0 | 104 | const nsDisplayListSet& aLists); |
michael@0 | 105 | |
michael@0 | 106 | nsRect mLineRect; |
michael@0 | 107 | nsMathMLChar* mSlashChar; |
michael@0 | 108 | nscoord mLineThickness; |
michael@0 | 109 | bool mIsBevelled; |
michael@0 | 110 | }; |
michael@0 | 111 | |
michael@0 | 112 | #endif /* nsMathMLmfracFrame_h___ */ |