Changeset 132076 in webkit


Ignore:
Timestamp:
Oct 22, 2012 8:52:23 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[css3-text] Add rendering support for -webkit-text-decoration-style
https://bugs.webkit.org/show_bug.cgi?id=94094

Patch by Bruno de Oliveira Abinader <Bruno de Oliveira Abinader> on 2012-10-22
Reviewed by Julien Chaffraix.

Source/WebCore:

This patch implements the "text-decoration-style" property rendering as
specified in CSS3 working draft, with "-webkit-" prefix. The specification can
be found here: http://dev.w3.org/csswg/css3-text/#text-decoration-style

Additionally, Mozilla implementation details can be found here:
https://developer.mozilla.org/en/CSS/text-decoration-style

Tests: fast/css3-text/css3-text-decoration/repaint/repaint-text-decoration-style.html

fast/css3-text/css3-text-decoration/text-decoration-style.html

  • platform/graphics/GraphicsContext.h:
  • platform/graphics/cairo/GraphicsContextCairo.cpp:

(WebCore::GraphicsContext::setPlatformStrokeStyle):

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::drawLine):

  • platform/graphics/qt/GraphicsContextQt.cpp:

(WebCore::toQPenStyle):
(WebCore::GraphicsContext::drawLine):

  • platform/graphics/skia/PlatformContextSkia.cpp:

(WebCore::PlatformContextSkia::setupPaintForStroking):

  • platform/graphics/wince/GraphicsContextWinCE.cpp:

(WebCore::createPen):

  • platform/graphics/wx/GraphicsContextWx.cpp:

(WebCore::strokeStyleToWxPenStyle):
Added 'DoubleStroke' and 'WavyStroke' to StrokeStyle enum and updated
platform-specific stroke handling. Some styles requires
platform-specific implementation (handled in bug 92868).

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::paint):
(WebCore::textDecorationStyleToStrokeStyle): Added static function that
translates text decoration to stroke styles.
(WebCore::InlineTextBox::paintDecoration): Text decoration style does
not specify a property for line thickness (like border-width does for
border style), so we statically set it to 1 for now. The 'double' style
implementation simply adds a parallel line (depending if it is
underline, overline or line-through) and the space between lines follows
the approach used by border's 'double' style.

  • rendering/InlineTextBox.h:

(InlineTextBox):

  • rendering/style/RenderStyle.h:
  • rendering/style/RenderStyleConstants.h:

Added text decoration style rendering support to
InlineTextBox::paintDecoration().

LayoutTests:

Added paint and repaint layout tests for CSS3 text-decoration-style
property. Pixel results are not included due to missing platform support
for some decoration styles (handled on bug 93507). These are going
to be added when platform support is complete.

  • fast/css3-text/css3-text-decoration/repaint/repaint-text-decoration-style-expected.txt: Added.
  • fast/css3-text/css3-text-decoration/repaint/repaint-text-decoration-style.html: Added.
  • fast/css3-text/css3-text-decoration/text-decoration-style-expected.txt: Added.
  • fast/css3-text/css3-text-decoration/text-decoration-style.html: Added.
Location:
trunk
Files:
4 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r132071 r132076  
     12012-10-22  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
     2
     3        [css3-text] Add rendering support for -webkit-text-decoration-style
     4        https://bugs.webkit.org/show_bug.cgi?id=94094
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        Added paint and repaint layout tests for CSS3 text-decoration-style
     9        property. Pixel results are not included due to missing platform support
     10        for some decoration styles (handled on bug 93507). These are going
     11        to be added when platform support is complete.
     12
     13        * fast/css3-text/css3-text-decoration/repaint/repaint-text-decoration-style-expected.txt: Added.
     14        * fast/css3-text/css3-text-decoration/repaint/repaint-text-decoration-style.html: Added.
     15        * fast/css3-text/css3-text-decoration/text-decoration-style-expected.txt: Added.
     16        * fast/css3-text/css3-text-decoration/text-decoration-style.html: Added.
     17
    1182012-10-22  Erik Arvidsson  <arv@chromium.org>
    219
  • trunk/Source/WebCore/ChangeLog

    r132074 r132076  
     12012-10-22  Bruno de Oliveira Abinader  <bruno.abinader@basyskom.com>
     2
     3        [css3-text] Add rendering support for -webkit-text-decoration-style
     4        https://bugs.webkit.org/show_bug.cgi?id=94094
     5
     6        Reviewed by Julien Chaffraix.
     7
     8        This patch implements the "text-decoration-style" property rendering as
     9        specified in CSS3 working draft, with "-webkit-" prefix. The specification can
     10        be found here: http://dev.w3.org/csswg/css3-text/#text-decoration-style
     11
     12        Additionally, Mozilla implementation details can be found here:
     13        https://developer.mozilla.org/en/CSS/text-decoration-style
     14
     15        Tests: fast/css3-text/css3-text-decoration/repaint/repaint-text-decoration-style.html
     16               fast/css3-text/css3-text-decoration/text-decoration-style.html
     17
     18        * platform/graphics/GraphicsContext.h:
     19        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     20        (WebCore::GraphicsContext::setPlatformStrokeStyle):
     21        * platform/graphics/cg/GraphicsContextCG.cpp:
     22        (WebCore::GraphicsContext::drawLine):
     23        * platform/graphics/qt/GraphicsContextQt.cpp:
     24        (WebCore::toQPenStyle):
     25        (WebCore::GraphicsContext::drawLine):
     26        * platform/graphics/skia/PlatformContextSkia.cpp:
     27        (WebCore::PlatformContextSkia::setupPaintForStroking):
     28        * platform/graphics/wince/GraphicsContextWinCE.cpp:
     29        (WebCore::createPen):
     30        * platform/graphics/wx/GraphicsContextWx.cpp:
     31        (WebCore::strokeStyleToWxPenStyle):
     32        Added 'DoubleStroke' and 'WavyStroke' to StrokeStyle enum and updated
     33        platform-specific stroke handling. Some styles requires
     34        platform-specific implementation (handled in bug 92868).
     35        * rendering/InlineTextBox.cpp:
     36        (WebCore::InlineTextBox::paint):
     37        (WebCore::textDecorationStyleToStrokeStyle): Added static function that
     38        translates text decoration to stroke styles.
     39        (WebCore::InlineTextBox::paintDecoration): Text decoration style does
     40        not specify a property for line thickness (like border-width does for
     41        border style), so we statically set it to 1 for now. The 'double' style
     42        implementation simply adds a parallel line (depending if it is
     43        underline, overline or line-through) and the space between lines follows
     44        the approach used by border's 'double' style.
     45        * rendering/InlineTextBox.h:
     46        (InlineTextBox):
     47        * rendering/style/RenderStyle.h:
     48        * rendering/style/RenderStyleConstants.h:
     49        Added text decoration style rendering support to
     50        InlineTextBox::paintDecoration().
     51
    1522012-10-22  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    253
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r130636 r132076  
    138138        SolidStroke,
    139139        DottedStroke,
    140         DashedStroke
     140        DashedStroke,
     141#if ENABLE(CSS3_TEXT)
     142        DoubleStroke,
     143        WavyStroke,
     144#endif // CSS3_TEXT
    141145    };
    142146
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r129657 r132076  
    803803        break;
    804804    case SolidStroke:
     805#if ENABLE(CSS3_TEXT)
     806    case DoubleStroke:
     807    case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=94110 - Needs platform support.
     808#endif // CSS3_TEXT
    805809        cairo_set_dash(platformContext()->cr(), 0, 0, 0);
    806810        break;
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r130565 r132076  
    426426    case NoStroke:
    427427    case SolidStroke:
     428#if ENABLE(CSS3_TEXT)
     429    case DoubleStroke:
     430    case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=94112 - Needs platform support.
     431#endif // CSS3_TEXT
    428432        break;
    429433    case DottedStroke:
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r131663 r132076  
    157157        break;
    158158    case SolidStroke:
     159#if ENABLE(CSS3_TEXT)
     160    case DoubleStroke:
     161    case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=93507 - Needs platform support.
     162#endif
    159163        return Qt::SolidLine;
    160164        break;
     
    403407    case NoStroke:
    404408    case SolidStroke:
     409#if ENABLE(CSS3_TEXT)
     410    case DoubleStroke:
     411    case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=93507 - Needs platform support.
     412#endif
    405413        break;
    406414    case DottedStroke: {
  • trunk/Source/WebCore/platform/graphics/skia/PlatformContextSkia.cpp

    r130940 r132076  
    413413        case NoStroke:
    414414        case SolidStroke:
     415#if ENABLE(CSS3_TEXT)
     416        case DoubleStroke:
     417        case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=93509 - Needs platform support.
     418#endif // CSS3_TEXT
    415419            break;
    416420        case DashedStroke:
  • trunk/Source/WebCore/platform/graphics/wince/GraphicsContextWinCE.cpp

    r131577 r132076  
    355355    switch (style) {
    356356        case SolidStroke:
     357#if ENABLE(CSS3_TEXT)
     358        case DoubleStroke:
     359        case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=94114 - Needs platform support.
     360#endif // CSS3_TEXT
    357361            penStyle = PS_SOLID;
    358362            break;
  • trunk/Source/WebCore/platform/graphics/wx/GraphicsContextWx.cpp

    r124135 r132076  
    100100    if (p == DashedStroke)
    101101        return wxLONG_DASH;
     102#if ENABLE(CSS3_TEXT)
     103    if (p == DoubleStroke)
     104        return wxSOLID;
     105    if (p == WavyStroke) // FIXME: https://bugs.webkit.org/show_bug.cgi?id=94111 - Needs platform support.
     106        return wxSOLID;
     107#endif // CSS3_TEXT
    102108    if (p == NoStroke)
    103109        return wxTRANSPARENT;
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r131311 r132076  
    767767
    768768    // Paint decorations
    769     int textDecorations = styleToUse->textDecorationsInEffect();
     769    ETextDecoration textDecorations = styleToUse->textDecorationsInEffect();
    770770    if (textDecorations != TDNONE && paintInfo.phase != PaintPhaseSelection) {
    771771        updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
    772         paintDecoration(context, boxOrigin, textDecorations, textShadow);
     772        paintDecoration(context, boxOrigin, textDecorations, styleToUse->textDecorationStyle(), textShadow);
    773773    }
    774774
     
    926926#endif
    927927
    928 void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& boxOrigin, int deco, const ShadowData* shadow)
    929 {
     928static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle)
     929{
     930    StrokeStyle strokeStyle = SolidStroke;
     931    switch (decorationStyle) {
     932    case TextDecorationStyleSolid:
     933        strokeStyle = SolidStroke;
     934        break;
     935#if ENABLE(CSS3_TEXT)
     936    case TextDecorationStyleDouble:
     937        strokeStyle = DoubleStroke;
     938        break;
     939    case TextDecorationStyleDotted:
     940        strokeStyle = DottedStroke;
     941        break;
     942    case TextDecorationStyleDashed:
     943        strokeStyle = DashedStroke;
     944        break;
     945    case TextDecorationStyleWavy:
     946        // FIXME: https://bugs.webkit.org/show_bug.cgi?id=92868 - Needs platform support.
     947        strokeStyle = WavyStroke;
     948        break;
     949#endif // CSS3_TEXT
     950    }
     951
     952    return strokeStyle;
     953}
     954
     955void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& boxOrigin, ETextDecoration deco, TextDecorationStyle decorationStyle, const ShadowData* shadow)
     956{
     957    // FIXME: We should improve this rule and not always just assume 1.
     958    const float textDecorationThickness = 1.f;
     959
    930960    if (m_truncation == cFullTruncation)
    931961        return;
     
    948978    // Use a special function for underlines to get the positioning exactly right.
    949979    bool isPrinting = textRenderer()->document()->printing();
    950     context->setStrokeThickness(1.0f); // FIXME: We should improve this rule and not always just assume 1.
     980    context->setStrokeThickness(textDecorationThickness);
    951981
    952982    bool linesAreOpaque = !isPrinting && (!(deco & UNDERLINE) || underline.alpha() == 255) && (!(deco & OVERLINE) || overline.alpha() == 255) && (!(deco & LINE_THROUGH) || linethrough.alpha() == 255);
     
    9771007    ColorSpace colorSpace = renderer()->style()->colorSpace();
    9781008    bool setShadow = false;
    979    
     1009
    9801010    do {
    9811011        if (shadow) {
     
    9921022        }
    9931023
     1024#if ENABLE(CSS3_TEXT)
     1025        // Offset between lines - always non-zero, so lines never cross each other.
     1026        float doubleOffset = textDecorationThickness + 1.f;
     1027#endif // CSS3_TEXT
     1028        context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle));
    9941029        if (deco & UNDERLINE) {
    9951030            context->setStrokeColor(underline, colorSpace);
    996             context->setStrokeStyle(SolidStroke);
    9971031            // Leave one pixel of white between the baseline and the underline.
    9981032            context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + baseline + 1), width, isPrinting);
     1033#if ENABLE(CSS3_TEXT)
     1034            if (decorationStyle == TextDecorationStyleDouble)
     1035                context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + baseline + 1 + doubleOffset), width, isPrinting);
     1036#endif // CSS3_TEXT
    9991037        }
    10001038        if (deco & OVERLINE) {
    10011039            context->setStrokeColor(overline, colorSpace);
    1002             context->setStrokeStyle(SolidStroke);
    10031040            context->drawLineForText(localOrigin, width, isPrinting);
     1041#if ENABLE(CSS3_TEXT)
     1042            if (decorationStyle == TextDecorationStyleDouble)
     1043                context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() - doubleOffset), width, isPrinting);
     1044#endif // CSS3_TEXT
    10041045        }
    10051046        if (deco & LINE_THROUGH) {
    10061047            context->setStrokeColor(linethrough, colorSpace);
    1007             context->setStrokeStyle(SolidStroke);
    10081048            context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + 2 * baseline / 3), width, isPrinting);
     1049#if ENABLE(CSS3_TEXT)
     1050            if (decorationStyle == TextDecorationStyleDouble)
     1051                context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y() + doubleOffset + 2 * baseline / 3), width, isPrinting);
     1052#endif // CSS3_TEXT
    10091053        }
    10101054    } while (shadow);
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r131311 r132076  
    184184
    185185private:
    186     void paintDecoration(GraphicsContext*, const FloatPoint& boxOrigin, int decoration, const ShadowData*);
     186    void paintDecoration(GraphicsContext*, const FloatPoint& boxOrigin, ETextDecoration, TextDecorationStyle, const ShadowData*);
    187187    void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, RenderStyle*, const Font&, Color textColor);
    188188    void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&, bool grammar);
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r131925 r132076  
    620620#if ENABLE(CSS3_TEXT)
    621621    TextDecorationStyle textDecorationStyle() const { return static_cast<TextDecorationStyle>(rareNonInheritedData->m_textDecorationStyle); }
     622#else
     623    TextDecorationStyle textDecorationStyle() const { return TextDecorationStyleSolid; }
    622624#endif // CSS3_TEXT
    623625    int wordSpacing() const;
  • trunk/Source/WebCore/rendering/style/RenderStyleConstants.h

    r131925 r132076  
    337337inline ETextDecoration& operator|=(ETextDecoration& a, ETextDecoration b) { return a = a | b; }
    338338
    339 #if ENABLE(CSS3_TEXT)
    340339enum TextDecorationStyle {
    341340    TextDecorationStyleSolid,
     341#if ENABLE(CSS3_TEXT)
    342342    TextDecorationStyleDouble,
    343343    TextDecorationStyleDotted,
    344344    TextDecorationStyleDashed,
    345345    TextDecorationStyleWavy
    346 };
    347346#endif // CSS3_TEXT
     347};
    348348
    349349enum EPageBreak {
Note: See TracChangeset for help on using the changeset viewer.