Coverage Report

Created: 2018-09-25 14:53

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