Changeset 166902 in webkit


Ignore:
Timestamp:
Apr 7, 2014 6:35:19 PM (10 years ago)
Author:
Martin Robinson
Message:

fast/css3-text/css3-text-decoration/text-decoration-thickness.html fails on GTK
https://bugs.webkit.org/show_bug.cgi?id=129957

Reviewed by Dean Jackson.

Source/WebCore:

Causes existing tests to pass.

  • platform/graphics/cairo/GraphicsContextCG.cpp: Use the now-shared computeLineBoundsAndAntialiasingModeForText.
  • platform/graphics/cairo/GraphicsContextCairo.cpp: Align the Cairo version of text underline drawing with the CG version.
  • platform/graphics/GraphicsContext.h: Add computeLineBoundsAndAntialiasingModeForText.
  • platform/graphics/GraphicsContext.cpp: Ditto.

LayoutTests:

Unskipped tests and modified one test to use the platform-independent Ahem font.

  • fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-tall-underlines.html: We

need to use Ahem because Helvetica is not a platform-independent font.

  • platform/gtk/TestExpectations: Unskipped tests.
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r166901 r166902  
     12014-04-07  Martin Robinson  <mrobinson@igalia.com>
     2
     3        fast/css3-text/css3-text-decoration/text-decoration-thickness.html fails on GTK
     4        https://bugs.webkit.org/show_bug.cgi?id=129957
     5
     6        Reviewed by Dean Jackson.
     7
     8        Unskipped tests and modified one test to use the platform-independent Ahem font.
     9
     10        * fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-tall-underlines.html: We
     11        need to use Ahem because Helvetica is not a platform-independent font.
     12        * platform/gtk/TestExpectations: Unskipped tests.
     13
    1142014-04-07  Brian J. Burg  <burg@cs.washington.edu>
    215
  • trunk/LayoutTests/fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-tall-underlines.html

    r161573 r166902  
    88an empty one.
    99<div style="position: relative; overflow: hidden; width: 36px; height: 100px;">
    10 <div style="left: -160px; top: -320px; position: absolute; -webkit-transform: scale(20); font-family: helvetica; -webkit-transform-origin: left top; display: inline-block; text-decoration: underline; -webkit-text-decoration-skip: ink;">gy</div>
     10<div style="left: -160px; top: -325px; position: absolute; -webkit-transform: scale(20); font-family: ahem; -webkit-transform-origin: left top; display: inline-block; text-decoration: underline; -webkit-text-decoration-skip: ink;">gy</div>
    1111</div>
    1212</body>
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r166875 r166902  
    13831383webkit.org/b/129180 svg/clip-path/clip-path-on-svg-002.svg [ ImageOnlyFailure ]
    13841384
    1385 webkit.org/b/129957 fast/css3-text/css3-text-decoration/text-decoration-thickness.html [ ImageOnlyFailure ]
    1386 webkit.org/b/129957 fast/css3-text/css3-text-decoration/text-decoration-style-double-space-scales.html [ ImageOnlyFailure ]
    1387 webkit.org/b/129957 fast/css3-text/css3-text-decoration/text-decoration-skip/text-decoration-skip-tall-underlines.html [ ImageOnlyFailure ]
    1388 
    13891385webkit.org/b/129958 svg/clip-path/mask-nested-clip-path-006.svg [ ImageOnlyFailure ]
    13901386webkit.org/b/129958 svg/clip-path/mask-nested-clip-path-007.svg [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r166895 r166902  
     12014-04-07  Martin Robinson  <mrobinson@igalia.com>
     2
     3        fast/css3-text/css3-text-decoration/text-decoration-thickness.html fails on GTK
     4        https://bugs.webkit.org/show_bug.cgi?id=129957
     5
     6        Reviewed by Dean Jackson.
     7
     8        Causes existing tests to pass.
     9
     10        * platform/graphics/cairo/GraphicsContextCG.cpp: Use the now-shared computeLineBoundsAndAntialiasingModeForText.
     11        * platform/graphics/cairo/GraphicsContextCairo.cpp: Align the Cairo version of text underline drawing with the CG version.
     12        * platform/graphics/GraphicsContext.h: Add computeLineBoundsAndAntialiasingModeForText.
     13        * platform/graphics/GraphicsContext.cpp: Ditto.
     14
    1152014-04-07  Beth Dakin  <bdakin@apple.com>
    216
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r166644 r166902  
    960960#endif
    961961
    962 }
     962FloatRect GraphicsContext::computeLineBoundsAndAntialiasingModeForText(const FloatPoint& point, float width, bool printing, bool& shouldAntialias, Color& color)
     963{
     964    FloatPoint origin;
     965    float thickness = std::max(strokeThickness(), 0.5f);
     966
     967    shouldAntialias = true;
     968    if (printing)
     969        origin = point;
     970    else {
     971        AffineTransform transform = getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
     972        if (transform.preservesAxisAlignment())
     973            shouldAntialias = false;
     974
     975        // This code always draws a line that is at least one-pixel line high,
     976        // which tends to visually overwhelm text at small scales. To counter this
     977        // effect, an alpha is applied to the underline color when text is at small scales.
     978
     979        // Just compute scale in x dimension, assuming x and y scales are equal.
     980        float scale = transform.b() ? sqrtf(transform.a() * transform.a() + transform.b() * transform.b()) : transform.a();
     981        if (scale < 1.0) {
     982            static const float minimumUnderlineAlpha = 0.4f;
     983            float shade = scale > minimumUnderlineAlpha ? scale : minimumUnderlineAlpha;
     984            int alpha = color.alpha() * shade;
     985            color = Color(color.red(), color.green(), color.blue(), alpha);
     986        }
     987
     988        // Don't offset line from bottom of text if scale is less than offsetUnderLineScale.
     989        static const float offsetUnderlineScale = 0.4f;
     990        float dy = scale < offsetUnderlineScale ? 0 : 1;
     991
     992        // If we've increased the thickness of the line, make sure to move the location too.
     993        if (thickness > 1)
     994            dy += roundf(thickness) - 1;
     995
     996        FloatPoint devicePoint = transform.mapPoint(point);
     997        FloatPoint deviceOrigin = FloatPoint(roundf(devicePoint.x()), ceilf(devicePoint.y()) + dy);
     998        origin = transform.inverse().mapPoint(deviceOrigin);
     999    }
     1000    return FloatRect(origin.x(), origin.y(), width, thickness);
     1001}
     1002
     1003}
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r166644 r166902  
    568568        void platformFillRoundedRect(const FloatRoundedRect&, const Color&, ColorSpace);
    569569
     570        FloatRect computeLineBoundsAndAntialiasingModeForText(const FloatPoint&, float width, bool printing, bool& shouldAntialias, Color&);
     571
    570572        GraphicsContextPlatformPrivate* m_data;
    571573
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r166100 r166902  
    617617}
    618618
    619 FloatRect GraphicsContext::computeLineBoundsForText(const FloatPoint& origin, float width, bool)
    620 {
    621     return FloatRect(origin, FloatSize(width, strokeThickness()));
     619FloatRect GraphicsContext::computeLineBoundsForText(const FloatPoint& origin, float width, bool printing)
     620{
     621    bool dummyBool;
     622    Color dummyColor;
     623    return computeLineBoundsAndAntialiasingModeForText(origin, width, printing, dummyBool, dummyColor);
    622624}
    623625
    624626void GraphicsContext::drawLineForText(const FloatPoint& origin, float width, bool printing, bool doubleUnderlines)
    625627{
    626     if (paintingDisabled())
    627         return;
    628 
    629     cairo_t* cairoContext = platformContext()->cr();
    630     cairo_save(cairoContext);
    631 
    632     // This bumping of <1 stroke thicknesses matches the one in drawLineOnCairoContext.
    633     FloatPoint endPoint(origin + IntSize(width, 0));
    634     FloatRect lineExtents = computeLineBoundsForText(origin, width, printing);
    635 
    636     ShadowBlur& shadow = platformContext()->shadowBlur();
    637     if (GraphicsContext* shadowContext = shadow.beginShadowLayer(this, lineExtents)) {
    638         drawLineOnCairoContext(this, shadowContext->platformContext()->cr(), origin, endPoint);
    639         if (doubleUnderlines)
    640             drawLineOnCairoContext(this, shadowContext->platformContext()->cr(), origin + FloatSize(0, strokeThickness() * 2), endPoint + FloatSize(0, strokeThickness() * 2));
    641         shadow.endShadowLayer(this);
    642     }
    643 
    644     drawLineOnCairoContext(this, cairoContext, origin, endPoint);
    645     if (doubleUnderlines)
    646         drawLineOnCairoContext(this, cairoContext, origin + FloatSize(0, strokeThickness() * 2), endPoint + FloatSize(0, strokeThickness() * 2));
    647     cairo_restore(cairoContext);
     628    DashArray widths;
     629    widths.append(width);
     630    widths.append(0);
     631    drawLinesForText(origin, widths, printing, doubleUnderlines);
    648632}
    649633
    650634void GraphicsContext::drawLinesForText(const FloatPoint& point, const DashArray& widths, bool printing, bool doubleUnderlines)
    651635{
     636    if (paintingDisabled())
     637        return;
     638
     639    if (widths.size() <= 0)
     640        return;
     641
     642    Color localStrokeColor(strokeColor());
     643
     644    bool shouldAntialiasLine;
     645    FloatRect bounds = computeLineBoundsAndAntialiasingModeForText(point, widths.last(), printing, shouldAntialiasLine, localStrokeColor);
     646
     647    Vector<FloatRect, 4> dashBounds;
     648    ASSERT(!(widths.size() % 2));
     649    dashBounds.reserveInitialCapacity(dashBounds.size() / 2);
    652650    for (size_t i = 0; i < widths.size(); i += 2)
    653         drawLineForText(FloatPoint(point.x() + widths[i], point.y()), widths[i+1] - widths[i], printing, doubleUnderlines);
     651        dashBounds.append(FloatRect(FloatPoint(bounds.x() + widths[i], bounds.y()), FloatSize(widths[i+1] - widths[i], bounds.height())));
     652
     653    if (doubleUnderlines) {
     654        // The space between double underlines is equal to the height of the underline
     655        for (size_t i = 0; i < widths.size(); i += 2)
     656            dashBounds.append(FloatRect(FloatPoint(bounds.x() + widths[i], bounds.y() + 2 * bounds.height()), FloatSize(widths[i+1] - widths[i], bounds.height())));
     657    }
     658
     659    cairo_t* cr = platformContext()->cr();
     660    cairo_save(cr);
     661
     662    for (auto& dash : dashBounds)
     663        fillRectWithColor(cr, dash, localStrokeColor);
     664
     665    cairo_restore(cr);
    654666}
    655667
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r166746 r166902  
    13531353}
    13541354
    1355 static FloatRect computeLineBoundsAndAntialiasingModeForText(GraphicsContext& initialContext, const FloatPoint& point, float width, bool printing, bool& shouldAntialias, Color& color)
    1356 {
    1357     CGContextRef context = initialContext.platformContext();
    1358     CGPoint origin;
    1359     CGFloat thickness = std::max(initialContext.strokeThickness(), 0.5f);
    1360 
    1361     shouldAntialias = true;
    1362     if (printing)
    1363         origin = CGPointMake(point.x(), point.y());
    1364     else {
    1365         CGAffineTransform t = CGContextGetUserSpaceToDeviceSpaceTransform(context);
    1366         if (AffineTransform(t).preservesAxisAlignment())
    1367             shouldAntialias = false;
    1368 
    1369         // This code always draws a line that is at least one-pixel line high,
    1370         // which tends to visually overwhelm text at small scales. To counter this
    1371         // effect, an alpha is applied to the underline color when text is at small scales.
    1372 
    1373         // Just compute scale in x dimension, assuming x and y scales are equal.
    1374         CGFloat scale = t.b ? sqrtf(t.a * t.a + t.b * t.b) : t.a;
    1375         if (scale < 1.0) {
    1376             static const float MinUnderlineAlpha = 0.4f;
    1377             float shade = scale > MinUnderlineAlpha ? scale : MinUnderlineAlpha;
    1378             int alpha = color.alpha() * shade;
    1379             color = Color(color.red(), color.green(), color.blue(), alpha);
    1380         }
    1381 
    1382         // Don't offset line from bottom of text if scale is less than OffsetUnderlineScale.
    1383         static const CGFloat OffsetUnderlineScale = 0.4f;
    1384         CGFloat dy = scale < OffsetUnderlineScale ? 0 : 1;
    1385 
    1386         // If we've increased the thickness of the line, make sure to move the location too.
    1387         if (thickness > 1)
    1388             dy += roundf(thickness) - 1;
    1389 
    1390         CGPoint devicePoint = CGPointApplyAffineTransform(point, t);
    1391         CGPoint deviceOrigin = CGPointMake(roundf(devicePoint.x), ceilf(devicePoint.y) + dy);
    1392         origin = CGPointApplyAffineTransform(deviceOrigin, CGAffineTransformInvert(t));
    1393     }
    1394     return FloatRect(origin.x, origin.y, width, thickness);
    1395 }
    1396 
    13971355FloatRect GraphicsContext::computeLineBoundsForText(const FloatPoint& point, float width, bool printing)
    13981356{
    13991357    bool dummyBool;
    14001358    Color dummyColor;
    1401     return computeLineBoundsAndAntialiasingModeForText(*this, point, width, printing, dummyBool, dummyColor);
     1359    return computeLineBoundsAndAntialiasingModeForText(point, width, printing, dummyBool, dummyColor);
    14021360}
    14031361
     
    14211379
    14221380    bool shouldAntialiasLine;
    1423     FloatRect bounds = computeLineBoundsAndAntialiasingModeForText(*this, point, widths.last(), printing, shouldAntialiasLine, localStrokeColor);
     1381    FloatRect bounds = computeLineBoundsAndAntialiasingModeForText(point, widths.last(), printing, shouldAntialiasLine, localStrokeColor);
    14241382    bool fillColorIsNotEqualToStrokeColor = fillColor() != localStrokeColor;
    14251383   
Note: See TracChangeset for help on using the changeset viewer.