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 MATHMLTEXTRUNFACTORY_H_
8 #define MATHMLTEXTRUNFACTORY_H_
9 
10 #include "mozilla/UniquePtr.h"
11 #include "nsTextRunTransformations.h"
12 
13 /**
14  * Builds textruns that render their text with MathML specific renderings.
15  */
16 class MathMLTextRunFactory : public nsTransformingTextRunFactory {
17  public:
MathMLTextRunFactory(mozilla::UniquePtr<nsTransformingTextRunFactory> aInnerTransformingTextRunFactory,uint32_t aFlags,uint8_t aSSTYScriptLevel,float aFontInflation)18   MathMLTextRunFactory(mozilla::UniquePtr<nsTransformingTextRunFactory>
19                            aInnerTransformingTextRunFactory,
20                        uint32_t aFlags, uint8_t aSSTYScriptLevel,
21                        float aFontInflation)
22       : mInnerTransformingTextRunFactory(
23             std::move(aInnerTransformingTextRunFactory)),
24         mFlags(aFlags),
25         mFontInflation(aFontInflation),
26         mSSTYScriptLevel(aSSTYScriptLevel) {}
27 
28   virtual void RebuildTextRun(nsTransformedTextRun* aTextRun,
29                               mozilla::gfx::DrawTarget* aRefDrawTarget,
30                               gfxMissingFontRecorder* aMFR) override;
31   enum {
32     // Style effects which may override single character <mi> behaviour
33     MATH_FONT_STYLING_NORMAL = 0x1,  // fontstyle="normal" has been set.
34     MATH_FONT_WEIGHT_BOLD = 0x2,     // fontweight="bold" has been set.
35     MATH_FONT_FEATURE_DTLS = 0x4,    // font feature dtls should be set
36   };
37 
38  protected:
39   mozilla::UniquePtr<nsTransformingTextRunFactory>
40       mInnerTransformingTextRunFactory;
41   uint32_t mFlags;
42   float mFontInflation;
43   uint8_t mSSTYScriptLevel;
44 };
45 
46 #endif /*MATHMLTEXTRUNFACTORY_H_*/
47