Changeset 141542 in webkit


Ignore:
Timestamp:
Jan 31, 2013 11:26:02 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt] Add support for text decoration "wavy" style
https://bugs.webkit.org/show_bug.cgi?id=93507

Patch by Lamarque V. Souza <Lamarque.Souza@basyskom.com> on 2013-01-31
Reviewed by Simon Hausmann.

Source/WebCore:

Add support for text decoration "wavy" style for Qt platform.

  • platform/graphics/qt/GraphicsContextQt.cpp:

(WebCore::toQPenStyle):
Remove FIXME comments obsoleted by this patch.
(WebCore::GraphicsContext::drawLine):
Implement wavy style line tracer.

LayoutTests:

Add pixel-test expected results for CSS3 text decoration tests for Qt port.

  • platform/qt-5.0-wk1/fast/css3-text/css3-text-decoration/repaint/repaint-text-decoration-style-expected.png: Added.
  • platform/qt-5.0-wk1/fast/css3-text/css3-text-decoration/text-decoration-style-expected.png: Added.
Location:
trunk
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141532 r141542  
     12013-01-31  Lamarque V. Souza  <Lamarque.Souza@basyskom.com>
     2
     3        [Qt] Add support for text decoration "wavy" style
     4        https://bugs.webkit.org/show_bug.cgi?id=93507
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Add pixel-test expected results for CSS3 text decoration tests for Qt port.
     9
     10        * platform/qt-5.0-wk1/fast/css3-text/css3-text-decoration/repaint/repaint-text-decoration-style-expected.png: Added.
     11        * platform/qt-5.0-wk1/fast/css3-text/css3-text-decoration/text-decoration-style-expected.png: Added.
     12
    1132013-01-31  Hajime Morrita  <morrita@google.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r141541 r141542  
     12013-01-31  Lamarque V. Souza  <Lamarque.Souza@basyskom.com>
     2
     3        [Qt] Add support for text decoration "wavy" style
     4        https://bugs.webkit.org/show_bug.cgi?id=93507
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Add support for text decoration "wavy" style for Qt platform.
     9
     10        * platform/graphics/qt/GraphicsContextQt.cpp:
     11        (WebCore::toQPenStyle):
     12        Remove FIXME comments obsoleted by this patch.
     13        (WebCore::GraphicsContext::drawLine):
     14        Implement wavy style line tracer.
     15
    1162013-01-31  Nils Barth  <nbarth@google.com>
    217
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r141413 r141542  
    161161#if ENABLE(CSS3_TEXT)
    162162    case DoubleStroke:
    163     case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=93507 - Needs platform support.
     163    case WavyStroke:
    164164#endif
    165165        return Qt::SolidLine;
     
    411411#if ENABLE(CSS3_TEXT)
    412412    case DoubleStroke:
    413     case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=93507 - Needs platform support.
     413    case WavyStroke:
    414414#endif
    415415        break;
     
    475475    }
    476476
     477#if ENABLE(CSS3_TEXT)
     478    if (style == WavyStroke) {
     479        const float step = 2 * width; // Make wave height equal to two times strokeThickness().
     480        const float flat = width; // Set size of flat lines between diagonal lines.
     481        short signal = -1;
     482        QPainterPath path;
     483        float x1, y1, x2, y2;
     484
     485        if (isVerticalLine) {
     486            x1 = x2 = p1.x();
     487
     488            // Make sure (x1, y1) < (x2, y2)
     489            if (p1.y() < p2.y()) {
     490                y1 = p1.y();
     491                y2 = p2.y();
     492            } else {
     493                y1 = p2.y();
     494                y2 = p1.y();
     495            }
     496
     497            // Qt interprets geometric units as end-point inclusive, while WebCore interprets geometric units as endpoint exclusive.
     498            // This means we need to subtract one from the endpoint, or the line will be painted one pixel too long.
     499            y2 -= 1;
     500            path.moveTo(x1 + signal * step, y1);
     501            float y = y1 + 2 * step;
     502
     503            while (y <= y2) {
     504                signal = -signal;
     505                path.lineTo(x1 + signal * step, y);
     506                path.lineTo(x1 + signal * step, y + flat); // Draw flat line between diagonal lines.
     507                y += 2 * step + flat;
     508            }
     509        } else {
     510            y1 = y2 = p1.y();
     511
     512            // Make sure (x1, y1) < (x2, y2)
     513            if (p1.x() < p2.x()) {
     514                x1 = p1.x();
     515                x2 = p2.x();
     516            } else {
     517                x1 = p2.x();
     518                x2 = p1.x();
     519            }
     520
     521            // Qt interprets geometric units as end-point inclusive, while WebCore interprets geometric units as endpoint exclusive.
     522            // This means we need to subtract one from the endpoint, or the line will be painted one pixel too long.
     523            x2 -= 1;
     524            path.moveTo(x1, y1 + signal * step);
     525            float x = x1 + 2 * step;
     526
     527            while (x <= x2) {
     528                signal = -signal;
     529                path.lineTo(x, y1 + signal * step);
     530                path.lineTo(x + flat, y1 + signal * step); // Draw flat line between diagonal lines.
     531                x += 2 * step + flat;
     532            }
     533        }
     534
     535        // The last point created by the while loops above may not be the end
     536        // point, so complete the wave by connecting the end point.
     537        path.lineTo(x2, y2);
     538        QPen pen = p->pen();
     539        pen.setJoinStyle(Qt::BevelJoin); // A bevelled line join is more suitable for wavy than miter or round.
     540        pen.setWidth(width);
     541        const bool oldAntiAliasing = p->testRenderHint(QPainter::Antialiasing);
     542        p->setRenderHint(QPainter::Antialiasing, true); // AntiAliasing is needed for diagonal lines of wavy stroke
     543        p->strokePath(path, pen);
     544        p->setRenderHint(QPainter::Antialiasing, oldAntiAliasing);
     545    } else {
     546#endif // CSS3_TEXT
    477547    // Qt interprets geometric units as end-point inclusive, while WebCore interprets geomtric units as endpoint exclusive.
    478548    // This means we need to subtract one from the endpoint, or the line will be painted one pixel too long.
     
    481551    else
    482552        p->drawLine(p1, p2 - FloatSize(1, 0));
     553#if ENABLE(CSS3_TEXT)
     554    }
     555#endif // CSS3_TEXT
    483556
    484557    if (patWidth)
Note: See TracChangeset for help on using the changeset viewer.