Changeset 165608 in webkit


Ignore:
Timestamp:
Mar 14, 2014 1:36:07 AM (10 years ago)
Author:
fred.wang@free.fr
Message:

Migrate the MathML stretchy code from UChar to Glyph.
https://bugs.webkit.org/show_bug.cgi?id=128907

Reviewed by Chris Fleizach.

This prepares the MathML stretchy code for future support for the MATH
table. In particular, this uses the glyph index for measuring and
drawing instead of Unicode code point since the MATH table uses glyph
indices. Also, this merges the preferred width and stretchy character
selection into one common path since they will also have to share the
size variants measuring/selection. Finally, we expose a drawGlyphs()
method so that we can draw a glyph by index.

No new tests. This should not change the behavior of the stretchy code.

  • platform/graphics/Font.h:
  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::drawGlyphs):

  • platform/graphics/GraphicsContext.h:
  • rendering/mathml/RenderMathMLOperator.cpp:

(WebCore::RenderMathMLOperator::RenderMathMLOperator):
(WebCore::RenderMathMLOperator::boundsForGlyph):
(WebCore::RenderMathMLOperator::heightForGlyph):
(WebCore::RenderMathMLOperator::advanceForGlyph):
(WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
(WebCore::RenderMathMLOperator::findStretchyData):
(WebCore::RenderMathMLOperator::updateStyle):
(WebCore::RenderMathMLOperator::firstLineBaseline):
(WebCore::RenderMathMLOperator::computeLogicalHeight):
(WebCore::RenderMathMLOperator::paintGlyph):
(WebCore::RenderMathMLOperator::fillWithExtensionGlyph):
(WebCore::RenderMathMLOperator::paint):
(WebCore::RenderMathMLOperator::paintChildren):

  • rendering/mathml/RenderMathMLOperator.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r165607 r165608  
     12014-03-14  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Migrate the MathML stretchy code from UChar to Glyph.
     4        https://bugs.webkit.org/show_bug.cgi?id=128907
     5
     6        Reviewed by Chris Fleizach.
     7
     8        This prepares the MathML stretchy code for future support for the MATH
     9        table. In particular, this uses the glyph index for measuring and
     10        drawing instead of Unicode code point since the MATH table uses glyph
     11        indices. Also, this merges the preferred width and stretchy character
     12        selection into one common path since they will also have to share the
     13        size variants measuring/selection. Finally, we expose a drawGlyphs()
     14        method so that we can draw a glyph by index.
     15
     16        No new tests. This should not change the behavior of the stretchy code.
     17
     18        * platform/graphics/Font.h:
     19        * platform/graphics/GraphicsContext.cpp:
     20        (WebCore::GraphicsContext::drawGlyphs):
     21        * platform/graphics/GraphicsContext.h:
     22        * rendering/mathml/RenderMathMLOperator.cpp:
     23        (WebCore::RenderMathMLOperator::RenderMathMLOperator):
     24        (WebCore::RenderMathMLOperator::boundsForGlyph):
     25        (WebCore::RenderMathMLOperator::heightForGlyph):
     26        (WebCore::RenderMathMLOperator::advanceForGlyph):
     27        (WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
     28        (WebCore::RenderMathMLOperator::findStretchyData):
     29        (WebCore::RenderMathMLOperator::updateStyle):
     30        (WebCore::RenderMathMLOperator::firstLineBaseline):
     31        (WebCore::RenderMathMLOperator::computeLogicalHeight):
     32        (WebCore::RenderMathMLOperator::paintGlyph):
     33        (WebCore::RenderMathMLOperator::fillWithExtensionGlyph):
     34        (WebCore::RenderMathMLOperator::paint):
     35        (WebCore::RenderMathMLOperator::paintChildren):
     36        * rendering/mathml/RenderMathMLOperator.h:
     37
    1382014-03-12  Sergio Villar Senin  <svillar@igalia.com>
    239
  • trunk/Source/WebCore/platform/graphics/Font.h

    r164842 r165608  
    112112    enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady };
    113113    float drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
     114    void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&) const;
    114115    void drawEmphasisMarks(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1) const;
    115116
     
    195196    float drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
    196197    void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const;
    197     void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const;
    198198    void drawGlyphBuffer(GraphicsContext*, const TextRun&, const GlyphBuffer&, FloatPoint&) const;
    199199    void drawEmphasisMarks(GraphicsContext*, const TextRun&, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const;
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r165055 r165608  
    459459#endif // !PLATFORM(IOS)
    460460
     461void GraphicsContext::drawGlyphs(const Font& font, const SimpleFontData& fontData, const GlyphBuffer& buffer, int from, int numGlyphs, const FloatPoint& point)
     462{
     463    if (paintingDisabled())
     464        return;
     465
     466    font.drawGlyphs(this, &fontData, buffer, from, numGlyphs, point);
     467}
     468
    461469void GraphicsContext::drawEmphasisMarks(const Font& font, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to)
    462470{
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r165055 r165608  
    351351        float drawText(const Font&, const TextRun&, const FloatPoint&, int from = 0, int to = -1);
    352352#endif
     353        void drawGlyphs(const Font&, const SimpleFontData&, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&);
    353354        void drawEmphasisMarks(const Font&, const TextRun& , const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1);
    354355#if !PLATFORM(IOS)
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r165464 r165608  
    4141#include "TransformOperations.h"
    4242#include <wtf/MathExtras.h>
     43#include <wtf/unicode/CharacterNames.h>
    4344
    4445namespace WebCore {
     
    4748
    4849// FIXME: The OpenType MATH table contains information that should override this table (http://wkbug/122297).
    49 static RenderMathMLOperator::StretchyCharacter stretchyCharacters[14] = {
     50struct StretchyCharacter {
     51    UChar character;
     52    UChar topChar;
     53    UChar extensionChar;
     54    UChar bottomChar;
     55    UChar middleChar;
     56};
     57static const StretchyCharacter stretchyCharacters[14] = {
    5058    { 0x28  , 0x239b, 0x239c, 0x239d, 0x0    }, // left parenthesis
    5159    { 0x29  , 0x239e, 0x239f, 0x23a0, 0x0    }, // right parenthesis
     
    11241132    , m_stretchDepthBelowBaseline(0)
    11251133    , m_operator(0)
    1126     , m_stretchyCharacter(nullptr)
    11271134{
    11281135    updateTokenContent();
     
    11341141    , m_stretchDepthBelowBaseline(0)
    11351142    , m_operator(0)
    1136     , m_stretchyCharacter(nullptr)
    11371143    , m_operatorForm(form)
    11381144    , m_operatorFlags(flag)
     
    12771283}
    12781284
    1279 FloatRect RenderMathMLOperator::glyphBoundsForCharacter(UChar character)
    1280 {
    1281     GlyphData data = style().font().glyphDataForCharacter(character, false);
     1285FloatRect RenderMathMLOperator::boundsForGlyph(const GlyphData& data)
     1286{
    12821287    return data.fontData->boundsForGlyph(data.glyph);
    12831288}
    12841289
    1285 float RenderMathMLOperator::glyphHeightForCharacter(UChar character)
    1286 {
    1287     return glyphBoundsForCharacter(character).height();
    1288 }
    1289 
    1290 float RenderMathMLOperator::advanceForCharacter(UChar character)
    1291 {
    1292     GlyphData data = style().font().glyphDataForCharacter(character, false);
     1290float RenderMathMLOperator::heightForGlyph(const GlyphData& data)
     1291{
     1292    return boundsForGlyph(data).height();
     1293}
     1294
     1295float RenderMathMLOperator::advanceForGlyph(const GlyphData& data)
     1296{
    12931297    return data.fontData->widthForGlyph(data.glyph);
    12941298}
     
    13051309        if (isInvisibleOperator()) {
    13061310            // In some fonts, glyphs for invisible operators have nonzero width. Consequently, we subtract that width here to avoid wide gaps.
    1307             float glyphWidth = advanceForCharacter(m_operator);
     1311            GlyphData data = style().font().glyphDataForCharacter(m_operator, false);
     1312            float glyphWidth = advanceForGlyph(data);
    13081313            ASSERT(glyphWidth <= m_minPreferredLogicalWidth);
    13091314            m_minPreferredLogicalWidth -= glyphWidth;
     
    13131318    }
    13141319
    1315     float maximumGlyphWidth = advanceForCharacter(stretchedCharacter);
    1316     for (unsigned index = 0; index < WTF_ARRAY_LENGTH(stretchyCharacters); ++index) {
    1317         if (stretchyCharacters[index].character != stretchedCharacter)
    1318             continue;
    1319 
    1320         StretchyCharacter& character = stretchyCharacters[index];
    1321         if (character.topGlyph)
    1322             maximumGlyphWidth = std::max(maximumGlyphWidth, advanceForCharacter(character.topGlyph));
    1323         if (character.extensionGlyph)
    1324             maximumGlyphWidth = std::max(maximumGlyphWidth, advanceForCharacter(character.extensionGlyph));
    1325         if (character.bottomGlyph)
    1326             maximumGlyphWidth = std::max(maximumGlyphWidth, advanceForCharacter(character.bottomGlyph));
    1327         if (character.middleGlyph)
    1328             maximumGlyphWidth = std::max(maximumGlyphWidth, advanceForCharacter(character.middleGlyph));
    1329         m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = m_leadingSpace + maximumGlyphWidth + m_trailingSpace;
    1330         return;
    1331     }
    1332 
     1320    GlyphData data = style().font().glyphDataForCharacter(stretchedCharacter, false);
     1321    float maximumGlyphWidth = advanceForGlyph(data);
     1322    findStretchyData(stretchedCharacter, &maximumGlyphWidth);
    13331323    m_maxPreferredLogicalWidth = m_minPreferredLogicalWidth = m_leadingSpace + maximumGlyphWidth + m_trailingSpace;
    13341324}
     
    13921382
    13931383// FIXME: We should also look at alternate characters defined in the OpenType MATH table (http://wkbug/122297).
    1394 RenderMathMLOperator::StretchyCharacter* RenderMathMLOperator::findAcceptableStretchyCharacter(UChar character)
    1395 {
    1396     StretchyCharacter* stretchyCharacter = 0;
     1384RenderMathMLOperator::StretchyData RenderMathMLOperator::findStretchyData(UChar character, float* maximumGlyphWidth)
     1385{
     1386    // FIXME: This function should first try size variants.
     1387    StretchyData data;
     1388
     1389    const StretchyCharacter* stretchyCharacter = 0;
    13971390    const int maxIndex = WTF_ARRAY_LENGTH(stretchyCharacters);
    13981391    for (int index = 0; index < maxIndex; ++index) {
     
    14051398    // If we didn't find a stretchy character set for this character, we don't know how to stretch it.
    14061399    if (!stretchyCharacter)
    1407         return 0;
    1408 
    1409     float height = glyphHeightForCharacter(stretchyCharacter->topGlyph) + glyphHeightForCharacter(stretchyCharacter->bottomGlyph);
    1410     if (stretchyCharacter->middleGlyph)
    1411         height += glyphHeightForCharacter(stretchyCharacter->middleGlyph);
    1412 
     1400        return data;
     1401
     1402    // We convert the list of Unicode characters into a list of glyph data.
     1403    GlyphData top = style().font().glyphDataForCharacter(stretchyCharacter->topChar, false);
     1404    GlyphData extension = style().font().glyphDataForCharacter(stretchyCharacter->extensionChar, false);
     1405    GlyphData bottom = style().font().glyphDataForCharacter(stretchyCharacter->bottomChar, false);
     1406    GlyphData middle;
     1407    if (stretchyCharacter->middleChar)
     1408        middle = style().font().glyphDataForCharacter(stretchyCharacter->middleChar, false);
     1409
     1410    // If we are measuring the maximum width, verify each component.
     1411    if (maximumGlyphWidth) {
     1412        *maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceForGlyph(top));
     1413        *maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceForGlyph(extension));
     1414        if (middle.glyph)
     1415            *maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceForGlyph(middle));
     1416        *maximumGlyphWidth = std::max(*maximumGlyphWidth, advanceForGlyph(bottom));
     1417        return data;
     1418    }
     1419
     1420    float height = heightForGlyph(top) + heightForGlyph(bottom);
     1421    if (middle.glyph)
     1422        height += heightForGlyph(middle);
    14131423    if (height > stretchSize())
    1414         return 0;
    1415 
    1416     return stretchyCharacter;
     1424        return data;
     1425
     1426    data.setGlyphAssemblyMode(top, extension, bottom, middle);
     1427    return data;
    14171428}
    14181429
     
    14271438
    14281439    float stretchedCharacterHeight = style().fontMetrics().floatHeight();
    1429     m_isStretched = allowStretching && stretchSize() > stretchedCharacterHeight;
     1440    m_stretchyData.setNormalMode();
    14301441
    14311442    // Sometimes we cannot stretch an operator properly, so in that case, we should just use the original size.
    1432     m_stretchyCharacter = m_isStretched ? findAcceptableStretchyCharacter(stretchedCharacter) : 0;
    1433     if (!m_stretchyCharacter)
    1434         m_isStretched = false;
     1443    if (allowStretching && stretchSize() > stretchedCharacterHeight)
     1444        m_stretchyData = findStretchyData(stretchedCharacter, nullptr);
    14351445
    14361446    // We add spacing around the operator.
     
    14471457int RenderMathMLOperator::firstLineBaseline() const
    14481458{
    1449     if (m_isStretched)
     1459    if (m_stretchyData.mode() != DrawNormal)
    14501460        return m_stretchHeightAboveBaseline;
    14511461    return RenderMathMLToken::firstLineBaseline();
     
    14541464void RenderMathMLOperator::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues& computedValues) const
    14551465{
    1456     if (m_isStretched)
     1466    if (m_stretchyData.mode() != DrawNormal)
    14571467        logicalHeight = stretchSize();
    14581468    RenderBox::computeLogicalHeight(logicalHeight, logicalTop, computedValues);
    14591469}
    14601470
    1461 LayoutRect RenderMathMLOperator::paintCharacter(PaintInfo& info, UChar character, const LayoutPoint& origin, CharacterPaintTrimming trim)
    1462 {
    1463     GlyphData data = style().font().glyphDataForCharacter(character, false);
    1464     FloatRect glyphBounds = data.fontData->boundsForGlyph(data.glyph);
     1471LayoutRect RenderMathMLOperator::paintGlyph(PaintInfo& info, const GlyphData& data, const LayoutPoint& origin, GlyphPaintTrimming trim)
     1472{
     1473    FloatRect glyphBounds = boundsForGlyph(data);
    14651474
    14661475    LayoutRect glyphPaintRect(origin, LayoutSize(glyphBounds.x() + glyphBounds.width(), glyphBounds.height()));
     
    14931502    info.context->clip(clipBounds);
    14941503
    1495     info.context->drawText(style().font(), TextRun(&character, 1), origin);
     1504    GlyphBuffer buffer;
     1505    buffer.add(data.glyph, data.fontData, advanceForGlyph(data));
     1506    info.context->drawGlyphs(style().font(), *data.fontData, buffer, 0, 1, origin);
    14961507
    14971508    return glyphPaintRect;
     
    15001511void RenderMathMLOperator::fillWithExtensionGlyph(PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to)
    15011512{
    1502     ASSERT(m_stretchyCharacter);
    1503     ASSERT(m_stretchyCharacter->extensionGlyph);
     1513    ASSERT(m_stretchyData.mode() == DrawGlyphAssembly);
     1514    ASSERT(m_stretchyData.extension().glyph);
    15041515    ASSERT(from.y() <= to.y());
    15051516
     
    15101521    GraphicsContextStateSaver stateSaver(*info.context);
    15111522
    1512     FloatRect glyphBounds = glyphBoundsForCharacter(m_stretchyCharacter->extensionGlyph);
     1523    FloatRect glyphBounds = boundsForGlyph(m_stretchyData.extension());
    15131524
    15141525    // Clipping the extender region here allows us to draw the bottom extender glyph into the
     
    15251536
    15261537    while (lastPaintedGlyphRect.maxY() < to.y()) {
    1527         lastPaintedGlyphRect = paintCharacter(info, m_stretchyCharacter->extensionGlyph, glyphOrigin, TrimTopAndBottom);
     1538        lastPaintedGlyphRect = paintGlyph(info, m_stretchyData.extension(), glyphOrigin, TrimTopAndBottom);
    15281539        glyphOrigin.setY(glyphOrigin.y() + lastPaintedGlyphRect.height());
    15291540
     
    15411552        return;
    15421553
    1543     if (!m_isStretched && !m_stretchyCharacter) {
     1554    if (m_stretchyData.mode() == DrawNormal) {
    15441555        RenderMathMLToken::paint(info, paintOffset);
    15451556        return;
     
    15511562    info.context->setFillColor(style().visitedDependentColor(CSSPropertyColor), style().colorSpace());
    15521563
    1553     ASSERT(m_stretchyCharacter->topGlyph);
    1554     ASSERT(m_stretchyCharacter->bottomGlyph);
     1564    ASSERT(m_stretchyData.mode() == DrawGlyphAssembly);
     1565    ASSERT(m_stretchyData.top().glyph);
     1566    ASSERT(m_stretchyData.bottom().glyph);
    15551567
    15561568    // We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box.
     
    15581570    operatorTopLeft.move(m_leadingSpace, 0);
    15591571    operatorTopLeft = ceiledIntPoint(operatorTopLeft);
    1560     FloatRect topGlyphBounds = glyphBoundsForCharacter(m_stretchyCharacter->topGlyph);
     1572    FloatRect topGlyphBounds = boundsForGlyph(m_stretchyData.top());
    15611573    LayoutPoint topGlyphOrigin(operatorTopLeft.x(), operatorTopLeft.y() - topGlyphBounds.y());
    1562     LayoutRect topGlyphPaintRect = paintCharacter(info, m_stretchyCharacter->topGlyph, topGlyphOrigin, TrimBottom);
    1563 
    1564     FloatRect bottomGlyphBounds = glyphBoundsForCharacter(m_stretchyCharacter->bottomGlyph);
     1574    LayoutRect topGlyphPaintRect = paintGlyph(info, m_stretchyData.top(), topGlyphOrigin, TrimBottom);
     1575
     1576    FloatRect bottomGlyphBounds = boundsForGlyph(m_stretchyData.bottom());
    15651577    LayoutPoint bottomGlyphOrigin(operatorTopLeft.x(), operatorTopLeft.y() + offsetHeight() - (bottomGlyphBounds.height() + bottomGlyphBounds.y()));
    1566     LayoutRect bottomGlyphPaintRect = paintCharacter(info, m_stretchyCharacter->bottomGlyph, bottomGlyphOrigin, TrimTop);
    1567 
    1568     if (m_stretchyCharacter->middleGlyph) {
     1578    LayoutRect bottomGlyphPaintRect = paintGlyph(info, m_stretchyData.bottom(), bottomGlyphOrigin, TrimTop);
     1579
     1580    if (m_stretchyData.middle().glyph) {
    15691581        // Center the glyph origin between the start and end glyph paint extents. Then shift it half the paint height toward the bottom glyph.
    1570         FloatRect middleGlyphBounds = glyphBoundsForCharacter(m_stretchyCharacter->middleGlyph);
     1582        FloatRect middleGlyphBounds = boundsForGlyph(m_stretchyData.middle());
    15711583        LayoutPoint middleGlyphOrigin(operatorTopLeft.x(), topGlyphOrigin.y());
    15721584        middleGlyphOrigin.moveBy(LayoutPoint(0, (bottomGlyphPaintRect.y() - topGlyphPaintRect.maxY()) / 2.0));
    15731585        middleGlyphOrigin.moveBy(LayoutPoint(0, middleGlyphBounds.height() / 2.0));
    15741586
    1575         LayoutRect middleGlyphPaintRect = paintCharacter(info, m_stretchyCharacter->middleGlyph, middleGlyphOrigin, TrimTopAndBottom);
     1587        LayoutRect middleGlyphPaintRect = paintGlyph(info, m_stretchyData.middle(), middleGlyphOrigin, TrimTopAndBottom);
    15761588        fillWithExtensionGlyph(info, topGlyphPaintRect.minXMaxYCorner(), middleGlyphPaintRect.minXMinYCorner());
    15771589        fillWithExtensionGlyph(info, middleGlyphPaintRect.minXMaxYCorner(), bottomGlyphPaintRect.minXMinYCorner());
     
    15821594void RenderMathMLOperator::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect)
    15831595{
    1584     if (m_isStretched)
     1596    if (m_stretchyData.mode() != DrawNormal)
    15851597        return;
    15861598    RenderMathMLToken::paintChildren(paintInfo, paintOffset, paintInfoForChild, usePrintRect);
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h

    r165464 r165608  
    2929#if ENABLE(MATHML)
    3030
     31#include "GlyphPage.h"
    3132#include "MathMLElement.h"
    3233#include "RenderMathMLToken.h"
    33 #include <wtf/unicode/CharacterNames.h>
    3434
    3535namespace WebCore {
     
    7171    void paint(PaintInfo&, const LayoutPoint&);
    7272
    73     struct StretchyCharacter {
    74         UChar character;
    75         UChar topGlyph;
    76         UChar extensionGlyph;
    77         UChar bottomGlyph;
    78         UChar middleGlyph;
    79     };
    80 
    8173    void updateTokenContent(const String& operatorString);
    8274    void updateTokenContent() override final;
     
    9991
    10092    bool shouldAllowStretching(UChar& characterForStretching);
    101     StretchyCharacter* findAcceptableStretchyCharacter(UChar);
    10293
    103     FloatRect glyphBoundsForCharacter(UChar);
    104     float glyphHeightForCharacter(UChar);
    105     float advanceForCharacter(UChar);
     94    FloatRect boundsForGlyph(const GlyphData&);
     95    float heightForGlyph(const GlyphData&);
     96    float advanceForGlyph(const GlyphData&);
    10697
    107     enum CharacterPaintTrimming {
     98    // FIXME: DrawSizeVariant is not implemented yet.
     99    enum DrawMode {
     100        DrawNormal, DrawSizeVariant, DrawGlyphAssembly
     101    };
     102    class StretchyData {
     103    public:
     104        DrawMode mode() const { return m_mode; }
     105        GlyphData variant() const { return m_data[0]; }
     106        GlyphData top() const { return m_data[0]; }
     107        GlyphData extension() const { return m_data[1]; }
     108        GlyphData bottom() const { return m_data[2]; }
     109        GlyphData middle() const { return m_data[3]; }
     110
     111        void setNormalMode()
     112        {
     113            m_mode = DrawNormal;
     114        }
     115        void setSizeVariantMode(const GlyphData& variant)
     116        {
     117            m_mode = DrawSizeVariant;
     118            m_data[0] = variant;
     119        }
     120        void setGlyphAssemblyMode(const GlyphData& top, const GlyphData& extension, const GlyphData& bottom, const GlyphData& middle)
     121        {
     122            m_mode = DrawGlyphAssembly;
     123            m_data[0] = top;
     124            m_data[1] = extension;
     125            m_data[2] = bottom;
     126            m_data[3] = middle;
     127        }
     128        StretchyData()
     129            : m_mode(DrawNormal) { }
     130        StretchyData(const StretchyData& data)
     131        {
     132            switch (data.m_mode) {
     133            case DrawNormal:
     134                setNormalMode();
     135                break;
     136            case DrawSizeVariant:
     137                setSizeVariantMode(data.variant());
     138                break;
     139            case DrawGlyphAssembly:
     140                setGlyphAssemblyMode(data.top(), data.extension(), data.bottom(), data.middle());
     141                break;
     142            }
     143        }
     144    private:
     145        DrawMode m_mode;
     146        // FIXME: For OpenType fonts with a MATH table all the glyphs are from the same font, so we would only need to store the glyph indices here.
     147        GlyphData m_data[4];
     148    };
     149    StretchyData findStretchyData(UChar, float* maximumGlyphWidth);
     150   
     151    enum GlyphPaintTrimming {
    108152        TrimTop,
    109153        TrimBottom,
     
    111155    };
    112156
    113     LayoutRect paintCharacter(PaintInfo&, UChar, const LayoutPoint& origin, CharacterPaintTrimming);
     157    LayoutRect paintGlyph(PaintInfo&, const GlyphData&, const LayoutPoint& origin, GlyphPaintTrimming);
    114158    void fillWithExtensionGlyph(PaintInfo&, const LayoutPoint& from, const LayoutPoint& to);
    115159
    116160    LayoutUnit m_stretchHeightAboveBaseline;
    117161    LayoutUnit m_stretchDepthBelowBaseline;
    118     bool m_isStretched;
    119162
    120163    UChar m_operator;
    121     StretchyCharacter* m_stretchyCharacter;
     164    StretchyData m_stretchyData;
    122165    MathMLOperatorDictionary::Form m_operatorForm;
    123166    unsigned short m_operatorFlags;
Note: See TracChangeset for help on using the changeset viewer.