Changeset 169617 in webkit


Ignore:
Timestamp:
Jun 5, 2014 9:23:08 AM (10 years ago)
Author:
fred.wang@free.fr
Message:

Apply Character-level mirroring to stretchy operators in RTL mode.
https://bugs.webkit.org/show_bug.cgi?id=130839

Reviewed by Chris Fleizach.

Source/WebCore:
We add support for character-level mirroring for stretchy MathML operators in RTL mode.
Glyph-level mirroring (via the rtlm OpenType feature) will be handled in bug 130840.

Test: mathml/presentation/stretchy-rtl.html

  • rendering/mathml/RenderMathMLOperator.cpp: reorganize the Unicode stretchyCharacters table to make mirroring easy.

(WebCore::RenderMathMLOperator::computePreferredLogicalWidths): pass the right boolean to glyphDataForCharacter.
(WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator): ditto
(WebCore::RenderMathMLOperator::findStretchyData): ditto and change the index for the stretchyCharacters fallback.
(WebCore::RenderMathMLOperator::updateStyle): pass the right boolean to glyphDataForCharacter.
(WebCore::RenderMathMLOperator::paint): remove the FIXME comment.
(WebCore::RenderMathMLOperator::paintVerticalGlyphAssembly): switch the leading/trailing space in RTL mode.

LayoutTests:
Add some tests to verify that stretchy operators are correctly mirrored in RTL mode.

  • mathml/presentation/stretchy-rtl-expected.html: Added.
  • mathml/presentation/stretchy-rtl.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r169616 r169617  
     12014-06-05  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Apply Character-level mirroring to stretchy operators in RTL mode.
     4        https://bugs.webkit.org/show_bug.cgi?id=130839
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Add some tests to verify that stretchy operators are correctly mirrored in RTL mode.
     9
     10        * mathml/presentation/stretchy-rtl-expected.html: Added.
     11        * mathml/presentation/stretchy-rtl.html: Added.
     12
    1132014-06-05  Zoltan Horvath  <zoltan@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r169615 r169617  
     12014-06-05  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Apply Character-level mirroring to stretchy operators in RTL mode.
     4        https://bugs.webkit.org/show_bug.cgi?id=130839
     5
     6        Reviewed by Chris Fleizach.
     7
     8        We add support for character-level mirroring for stretchy MathML operators in RTL mode.
     9        Glyph-level mirroring (via the rtlm OpenType feature) will be handled in bug 130840.
     10
     11        Test: mathml/presentation/stretchy-rtl.html
     12
     13        * rendering/mathml/RenderMathMLOperator.cpp: reorganize the Unicode stretchyCharacters table to make mirroring easy.
     14        (WebCore::RenderMathMLOperator::computePreferredLogicalWidths): pass the right boolean to glyphDataForCharacter.
     15        (WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator): ditto
     16        (WebCore::RenderMathMLOperator::findStretchyData): ditto and change the index for the stretchyCharacters fallback.
     17        (WebCore::RenderMathMLOperator::updateStyle): pass the right boolean to glyphDataForCharacter.
     18        (WebCore::RenderMathMLOperator::paint): remove the FIXME comment.
     19        (WebCore::RenderMathMLOperator::paintVerticalGlyphAssembly): switch the leading/trailing space in RTL mode.
     20
    1212014-06-05  Zalan Bujtas  <zalan@apple.com>
    222
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r169607 r169617  
    5656    UChar middleChar;
    5757};
     58// The first leftRightPairsCount pairs correspond to left/right fences that can easily be mirrored in RTL.
     59static const short leftRightPairsCount = 5;
    5860static const StretchyCharacter stretchyCharacters[14] = {
    5961    { 0x28  , 0x239b, 0x239c, 0x239d, 0x0    }, // left parenthesis
    6062    { 0x29  , 0x239e, 0x239f, 0x23a0, 0x0    }, // right parenthesis
    6163    { 0x5b  , 0x23a1, 0x23a2, 0x23a3, 0x0    }, // left square bracket
     64    { 0x5d  , 0x23a4, 0x23a5, 0x23a6, 0x0    }, // right square bracket
     65    { 0x7b  , 0x23a7, 0x23aa, 0x23a9, 0x23a8 }, // left curly bracket
     66    { 0x7d  , 0x23ab, 0x23aa, 0x23ad, 0x23ac }, // right curly bracket
    6267    { 0x2308, 0x23a1, 0x23a2, 0x23a2, 0x0    }, // left ceiling
     68    { 0x2309, 0x23a4, 0x23a5, 0x23a5, 0x0    }, // right ceiling
    6369    { 0x230a, 0x23a2, 0x23a2, 0x23a3, 0x0    }, // left floor
    64     { 0x5d  , 0x23a4, 0x23a5, 0x23a6, 0x0    }, // right square bracket
    65     { 0x2309, 0x23a4, 0x23a5, 0x23a5, 0x0    }, // right ceiling
    6670    { 0x230b, 0x23a5, 0x23a5, 0x23a6, 0x0    }, // right floor
    67     { 0x7b  , 0x23a7, 0x23aa, 0x23a9, 0x23a8 }, // left curly bracket
    6871    { 0x7c  , 0x7c,   0x7c,   0x7c,   0x0    }, // vertical bar
    6972    { 0x2016, 0x2016, 0x2016, 0x2016, 0x0    }, // double vertical line
    7073    { 0x2225, 0x2225, 0x2225, 0x2225, 0x0    }, // parallel to
    71     { 0x7d  , 0x23ab, 0x23aa, 0x23ad, 0x23ac }, // right curly bracket
    7274    { 0x222b, 0x2320, 0x23ae, 0x2321, 0x0    } // integral sign
    7375};
     
    13401342    }
    13411343
    1342     GlyphData data = style().font().glyphDataForCharacter(m_operator, false);
     1344    GlyphData data = style().font().glyphDataForCharacter(m_operator, !style().isLeftToRightDirection());
    13431345    float maximumGlyphWidth = advanceForGlyph(data);
    13441346    if (!m_isVertical) {
     
    15151517
    15161518    const auto& primaryFontData = style().font().primaryFont();
    1517     GlyphData baseGlyph = style().font().glyphDataForCharacter(character, false);
     1519    GlyphData baseGlyph = style().font().glyphDataForCharacter(character, !style().isLeftToRightDirection());
    15181520    if (!primaryFontData || !primaryFontData->mathData() || baseGlyph.fontData != primaryFontData)
    15191521        return data;
     
    15471549
    15481550    const auto& primaryFontData = style().font().primaryFont();
    1549     GlyphData baseGlyph = style().font().glyphDataForCharacter(character, false);
     1551    GlyphData baseGlyph = style().font().glyphDataForCharacter(character, !style().isLeftToRightDirection());
    15501552   
    15511553    if (primaryFontData && primaryFontData->mathData() && baseGlyph.fontData == primaryFontData) {
     
    15811583            if (stretchyCharacters[index].character == character) {
    15821584                stretchyCharacter = &stretchyCharacters[index];
     1585                if (!style().isLeftToRightDirection() && index < leftRightPairsCount * 2) {
     1586                    // If we are in right-to-left direction we select the mirrored form by adding -1 or +1 according to the parity of index.
     1587                    index += index % 2 ? -1 : 1;
     1588                }
    15831589                break;
    15841590            }
     
    16541660    else {
    16551661        // We do not stretch if the base glyph is large enough.
    1656         GlyphData baseGlyph = style().font().glyphDataForCharacter(m_operator, false);
     1662        GlyphData baseGlyph = style().font().glyphDataForCharacter(m_operator, !style().isLeftToRightDirection());
    16571663        float baseSize = m_isVertical ? heightForGlyph(baseGlyph) : advanceForGlyph(baseGlyph);
    16581664        if (stretchSize() <= baseSize)
     
    18621868        return;
    18631869
    1864     // FIXME: This painting should work in RTL mode too (https://bugs.webkit.org/show_bug.cgi?id=123018).
    1865 
    18661870    GraphicsContextStateSaver stateSaver(*info.context);
    18671871    info.context->setFillColor(style().visitedDependentColor(CSSPropertyColor), style().colorSpace());
     
    18931897    // We are positioning the glyphs so that the edge of the tight glyph bounds line up exactly with the edges of our paint box.
    18941898    LayoutPoint operatorTopLeft = paintOffset + location();
    1895     operatorTopLeft.move(m_leadingSpace, 0);
     1899    operatorTopLeft.move(style().isLeftToRightDirection() ? m_leadingSpace : m_trailingSpace, 0);
    18961900    operatorTopLeft = ceiledIntPoint(operatorTopLeft);
    18971901    FloatRect topGlyphBounds = boundsForGlyph(m_stretchyData.top());
Note: See TracChangeset for help on using the changeset viewer.