Changeset 165464 in webkit


Ignore:
Timestamp:
Mar 12, 2014 2:49:59 AM (10 years ago)
Author:
fred.wang@free.fr
Message:

Invisible Operators should not add space.
https://bugs.webkit.org/show_bug.cgi?id=115786

Reviewed by Chris Fleizach.

Source/WebCore:

This change adds special handling for invisible operator to ensure they really behave as empty box. We now ignore their glyph widths and do not paint them.

Test: mathml/presentation/mo-invisible.html

  • rendering/mathml/RenderMathMLOperator.cpp:

(WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
(WebCore::RenderMathMLOperator::paint):

  • rendering/mathml/RenderMathMLOperator.h:

LayoutTests:

Add a reftest based on the examples of the MathML specification to verify that invisible operators do not add space.

  • mathml/presentation/mo-invisible-expected.html: Added.
  • mathml/presentation/mo-invisible.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r165461 r165464  
     12014-03-12  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Invisible Operators should not add space.
     4        https://bugs.webkit.org/show_bug.cgi?id=115786
     5
     6        Reviewed by Chris Fleizach.
     7
     8        Add a reftest based on the examples of the MathML specification to verify that invisible operators do not add space.
     9
     10        * mathml/presentation/mo-invisible-expected.html: Added.
     11        * mathml/presentation/mo-invisible.html: Added.
     12
    1132014-03-11  Frédéric Wang  <fred.wang@free.fr>
    214
  • trunk/Source/WebCore/ChangeLog

    r165461 r165464  
     12014-03-12  Frédéric Wang  <fred.wang@free.fr>
     2
     3        Invisible Operators should not add space.
     4        https://bugs.webkit.org/show_bug.cgi?id=115786
     5
     6        Reviewed by Chris Fleizach.
     7
     8        This change adds special handling for invisible operator to ensure they really behave as empty box. We now ignore their glyph widths and do not paint them.
     9
     10        Test: mathml/presentation/mo-invisible.html
     11
     12        * rendering/mathml/RenderMathMLOperator.cpp:
     13        (WebCore::RenderMathMLOperator::computePreferredLogicalWidths):
     14        (WebCore::RenderMathMLOperator::paint):
     15        * rendering/mathml/RenderMathMLOperator.h:
     16
    1172014-03-11  Frédéric Wang  <fred.wang@free.fr>
    218
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r165461 r165464  
    13031303    if (!allowStretching) {
    13041304        RenderMathMLToken::computePreferredLogicalWidths();
     1305        if (isInvisibleOperator()) {
     1306            // 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);
     1308            ASSERT(glyphWidth <= m_minPreferredLogicalWidth);
     1309            m_minPreferredLogicalWidth -= glyphWidth;
     1310            m_maxPreferredLogicalWidth -= glyphWidth;
     1311        }
    13051312        return;
    13061313    }
     
    15301537void RenderMathMLOperator::paint(PaintInfo& info, const LayoutPoint& paintOffset)
    15311538{
    1532     if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE)
     1539    // We skip painting for invisible operators too to avoid some "missing character" glyph to appear if appropriate math fonts are not available.
     1540    if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE || isInvisibleOperator())
    15331541        return;
    15341542
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h

    r165461 r165464  
    8888    virtual bool isRenderMathMLOperator() const override { return true; }
    8989    bool isFencedOperator() { return isAnonymous(); }
     90    // The following operators are invisible: U+2061 FUNCTION APPLICATION, U+2062 INVISIBLE TIMES, U+2063 INVISIBLE SEPARATOR, U+2064 INVISIBLE PLUS.
     91    bool isInvisibleOperator() const { return 0x2061 <= m_operator && m_operator <= 0x2064; }
    9092    virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
    9193    virtual void computePreferredLogicalWidths() override;
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLRow.cpp

    r165461 r165464  
    6060    for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
    6161        if (child->isRenderMathMLBlock()) {
    62             auto renderOperator = toRenderMathMLBlock(child)->unembellishedOperator();
    63             if (renderOperator)
     62            if (auto renderOperator = toRenderMathMLBlock(child)->unembellishedOperator())
    6463                renderOperator->updateOperatorProperties();
    6564        }
Note: See TracChangeset for help on using the changeset viewer.