layout/mathml/nsMathMLmfracFrame.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/mathml/nsMathMLmfracFrame.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsMathMLmfracFrame_h___
    1.10 +#define nsMathMLmfracFrame_h___
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "nsMathMLContainerFrame.h"
    1.14 +
    1.15 +//
    1.16 +// <mfrac> -- form a fraction from two subexpressions 
    1.17 +//
    1.18 +
    1.19 +/*
    1.20 +The MathML REC describes:
    1.21 +
    1.22 +The <mfrac> element is used for fractions. It can also be used to mark up 
    1.23 +fraction-like objects such as binomial coefficients and Legendre symbols. 
    1.24 +The syntax for <mfrac> is:
    1.25 +  <mfrac> numerator denominator </mfrac>
    1.26 +
    1.27 +Attributes of <mfrac>:
    1.28 +     Name                      values                     default 
    1.29 +  linethickness  number [ v-unit ] | thin | medium | thick  1 
    1.30 +
    1.31 +E.g., 
    1.32 +linethickness=2 actually means that linethickness=2*DEFAULT_THICKNESS
    1.33 +(DEFAULT_THICKNESS is not specified by MathML, see below.)
    1.34 +
    1.35 +The linethickness attribute indicates the thickness of the horizontal
    1.36 +"fraction bar", or "rule", typically used to render fractions. A fraction
    1.37 +with linethickness="0" renders without the bar, and might be used within
    1.38 +binomial coefficients. A linethickness greater than one might be used with
    1.39 +nested fractions. 
    1.40 +
    1.41 +In general, the value of linethickness can be a number, as a multiplier
    1.42 +of the default thickness of the fraction bar (the default thickness is
    1.43 +not specified by MathML), or a number with a unit of vertical length (see
    1.44 +Section 2.3.3), or one of the keywords medium (same as 1), thin (thinner
    1.45 +than 1, otherwise up to the renderer), or thick (thicker than 1, otherwise
    1.46 +up to the renderer). 
    1.47 +
    1.48 +The <mfrac> element sets displaystyle to "false", or if it was already
    1.49 +false increments scriptlevel by 1, within numerator and denominator.
    1.50 +These attributes are inherited by every element from its rendering 
    1.51 +environment, but can be set explicitly only on the <mstyle> 
    1.52 +element. 
    1.53 +*/
    1.54 +
    1.55 +class nsMathMLmfracFrame : public nsMathMLContainerFrame {
    1.56 +public:
    1.57 +  NS_DECL_FRAMEARENA_HELPERS
    1.58 +
    1.59 +  friend nsIFrame* NS_NewMathMLmfracFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
    1.60 +
    1.61 +  virtual eMathMLFrameType GetMathMLFrameType() MOZ_OVERRIDE;
    1.62 +
    1.63 +  virtual nsresult
    1.64 +  MeasureForWidth(nsRenderingContext& aRenderingContext,
    1.65 +                  nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE;
    1.66 +
    1.67 +  virtual nsresult
    1.68 +  Place(nsRenderingContext& aRenderingContext,
    1.69 +        bool                 aPlaceOrigin,
    1.70 +        nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE;
    1.71 +
    1.72 +  virtual void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
    1.73 +                                const nsRect&           aDirtyRect,
    1.74 +                                const nsDisplayListSet& aLists) MOZ_OVERRIDE;
    1.75 +
    1.76 +  NS_IMETHOD
    1.77 +  TransmitAutomaticData() MOZ_OVERRIDE;
    1.78 +
    1.79 +  // override the base method so that we can deal with the fraction line
    1.80 +  virtual nscoord
    1.81 +  FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize) MOZ_OVERRIDE;
    1.82 +
    1.83 +  // helper to translate the thickness attribute into a usable form
    1.84 +  static nscoord 
    1.85 +  CalcLineThickness(nsPresContext*  aPresContext,
    1.86 +                    nsStyleContext*  aStyleContext,
    1.87 +                    nsString&        aThicknessAttribute,
    1.88 +                    nscoord          onePixel,
    1.89 +                    nscoord          aDefaultRuleThickness);
    1.90 +
    1.91 +  uint8_t
    1.92 +  ScriptIncrement(nsIFrame* aFrame) MOZ_OVERRIDE;
    1.93 +
    1.94 +protected:
    1.95 +  nsMathMLmfracFrame(nsStyleContext* aContext) : nsMathMLContainerFrame(aContext) {}
    1.96 +  virtual ~nsMathMLmfracFrame();
    1.97 +  
    1.98 +  nsresult PlaceInternal(nsRenderingContext& aRenderingContext,
    1.99 +                         bool                 aPlaceOrigin,
   1.100 +                         nsHTMLReflowMetrics& aDesiredSize,
   1.101 +                         bool                 aWidthOnly);
   1.102 +
   1.103 +  // Display a slash
   1.104 +  void DisplaySlash(nsDisplayListBuilder* aBuilder,
   1.105 +                    nsIFrame* aFrame, const nsRect& aRect,
   1.106 +                    nscoord aThickness,
   1.107 +                    const nsDisplayListSet& aLists);
   1.108 +
   1.109 +  nsRect        mLineRect;
   1.110 +  nsMathMLChar* mSlashChar;
   1.111 +  nscoord       mLineThickness;
   1.112 +  bool          mIsBevelled;
   1.113 +};
   1.114 +
   1.115 +#endif /* nsMathMLmfracFrame_h___ */

mercurial