Changeset 52904 in webkit


Ignore:
Timestamp:
Jan 7, 2010 12:06:01 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-06 MORITA Hajime <morrita@gmail.com>

Reviewed by Nikolas Zimmermann.

SVG background color on selected text goes wrong when text has
gradient stroke.
https://bugs.webkit.org/show_bug.cgi?id=33069

Introduced SVGTextPaintSubphase like as PaintPhase on html painting,
and paint background and foreground in separate subphase.

  • svg/text/selection-background-color.xhtml: Added.
  • platform/mac/svg/text/selection-background-color-expected.checksum: Added.
  • platform/mac/svg/text/selection-background-color-expected.png: Added.
  • platform/mac/svg/text/selection-background-color-expected.txt: Added.
  • platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum:
  • platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.png:
  • platform/mac/svg/batik/text/textDecoration2-expected.checksum:
  • platform/mac/svg/batik/text/textDecoration2-expected.png:
  • platform/mac/svg/text/text-deco-01-b-expected.checksum:
  • platform/mac/svg/text/text-deco-01-b-expected.png:
  • platform/mac/svg/text/text-spacing-01-b-expected.checksum:
  • platform/mac/svg/text/text-spacing-01-b-expected.png:
  • platform/mac/svg/text/text-text-03-b-expected.checksum:
  • platform/mac/svg/text/text-text-03-b-expected.png:
  • platform/mac/svg/text/text-text-08-b-expected.checksum:
  • platform/mac/svg/text/text-text-08-b-expected.png: Re-baselined due to painting algorithm change.

2010-01-06 MORITA Hajime <morrita@gmail.com>

Reviewed by Nikolas Zimmermann.

SVG background color on selected text goes wrong when text has
gradient stroke.
https://bugs.webkit.org/show_bug.cgi?id=33069

Introduced SVGTextPaintSubphase like as PaintPhase on html painting,
and paint background and foreground in separate subphase.

Test: svg/text/selection-background-color.xhtml

  • rendering/SVGCharacterLayoutInfo.h: (WebCore::SVGTextChunkWalker::SVGTextChunkWalker): Added m_setupBackgroundCallback, m_setupForegroundCallback (WebCore::SVGTextChunkWalker::setupBackground): (WebCore::SVGTextChunkWalker::setupForeground): Added.
  • rendering/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::paintCharacters): pass SVGTextPaintInfo instead of SVGPaintServer
  • rendering/SVGInlineTextBox.h: (WebCore::SVGTextPaintSubphase): (WebCore::SVGTextPaintInfo::SVGTextPaintInfo): Added.
  • rendering/SVGRootInlineBox.cpp: (WebCore::SVGRootInlineBox::walkTextChunks): Invoke setupBackground() and setupForeground() (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupBackgroundCallback): (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupForegroundCallback): (WebCore::SVGRootInlineBoxPaintWalker::activePaintServer): Added. (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupFillCallback): (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback): (WebCore::SVGRootInlineBoxPaintWalker::chunkPortionCallback): (WebCore::SVGRootInlineBox::paint):
Location:
trunk
Files:
4 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r52902 r52904  
     12010-01-06  MORITA Hajime  <morrita@gmail.com>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVG background color on selected text goes wrong when text has
     6        gradient stroke.
     7        https://bugs.webkit.org/show_bug.cgi?id=33069
     8
     9        Introduced SVGTextPaintSubphase like as PaintPhase on html painting,
     10        and paint background and foreground in separate subphase.
     11
     12        * svg/text/selection-background-color.xhtml: Added.       
     13        * platform/mac/svg/text/selection-background-color-expected.checksum: Added.
     14        * platform/mac/svg/text/selection-background-color-expected.png: Added.
     15        * platform/mac/svg/text/selection-background-color-expected.txt: Added.
     16       
     17        * platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum:
     18        * platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.png:
     19        * platform/mac/svg/batik/text/textDecoration2-expected.checksum:
     20        * platform/mac/svg/batik/text/textDecoration2-expected.png:
     21        * platform/mac/svg/text/text-deco-01-b-expected.checksum:
     22        * platform/mac/svg/text/text-deco-01-b-expected.png:
     23        * platform/mac/svg/text/text-spacing-01-b-expected.checksum:
     24        * platform/mac/svg/text/text-spacing-01-b-expected.png:
     25        * platform/mac/svg/text/text-text-03-b-expected.checksum:
     26        * platform/mac/svg/text/text-text-03-b-expected.png:
     27        * platform/mac/svg/text/text-text-08-b-expected.checksum:
     28        * platform/mac/svg/text/text-text-08-b-expected.png:
     29        Re-baselined due to painting algorithm change.
     30
    1312010-01-06  Kinuko Yasuda  <kinuko@chromium.org>
    232
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum

    r44224 r52904  
    1 ed64b2908c6fd5df02a15fad56f67f34
     179668d80dfb1484b12447c78a0c9a53a
  • trunk/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.checksum

    r44224 r52904  
    1 1f13a12e4ab2a348b2614a3c70d0546d
     1593fd59c2f58e622f04fb9c00d7714b3
  • trunk/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.checksum

    r38121 r52904  
    1 a46864e6b6d1cea350560ea244072f85
     197154819a65cda5e8b6257183b7a90e1
  • trunk/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.checksum

    r38121 r52904  
    1 ace025910b4ff42dd0bee9701efc4b63
     1c1e3a98345d7a6b13e2928da86fbc55f
  • trunk/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.checksum

    r38121 r52904  
    1 31029bbce66db9348cd8953d473f7b30
     1dc67e8cf3194af25f470c49b7e9b600a
  • trunk/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.checksum

    r38540 r52904  
    1 9265c96312cfa4f95c85dd52edf268b5
     1a48969c2ed5c0596624855a08b116447
  • trunk/WebCore/ChangeLog

    r52902 r52904  
     12010-01-06  MORITA Hajime  <morrita@gmail.com>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVG background color on selected text goes wrong when text has
     6        gradient stroke.
     7        https://bugs.webkit.org/show_bug.cgi?id=33069
     8
     9        Introduced SVGTextPaintSubphase like as PaintPhase on html painting,
     10        and paint background and foreground in separate subphase.
     11       
     12        Test: svg/text/selection-background-color.xhtml
     13       
     14        * rendering/SVGCharacterLayoutInfo.h:
     15        (WebCore::SVGTextChunkWalker::SVGTextChunkWalker):
     16        Added m_setupBackgroundCallback, m_setupForegroundCallback
     17        (WebCore::SVGTextChunkWalker::setupBackground):
     18        (WebCore::SVGTextChunkWalker::setupForeground):
     19        Added.
     20        * rendering/SVGInlineTextBox.cpp:
     21        (WebCore::SVGInlineTextBox::paintCharacters):
     22        pass SVGTextPaintInfo instead of SVGPaintServer
     23        * rendering/SVGInlineTextBox.h:
     24        (WebCore::SVGTextPaintSubphase):
     25        (WebCore::SVGTextPaintInfo::SVGTextPaintInfo):
     26        Added.
     27        * rendering/SVGRootInlineBox.cpp:
     28        (WebCore::SVGRootInlineBox::walkTextChunks):
     29        Invoke setupBackground() and setupForeground()
     30        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupBackgroundCallback):
     31        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupForegroundCallback):
     32        (WebCore::SVGRootInlineBoxPaintWalker::activePaintServer):       
     33        Added.
     34        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupFillCallback):
     35        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback):
     36        (WebCore::SVGRootInlineBoxPaintWalker::chunkPortionCallback):
     37        (WebCore::SVGRootInlineBox::paint):
     38       
    1392010-01-06  Kinuko Yasuda  <kinuko@chromium.org>
    240
  • trunk/WebCore/rendering/SVGCharacterLayoutInfo.h

    r45624 r52904  
    299299    virtual void end(InlineBox*) = 0;
    300300   
     301    virtual bool setupBackground(InlineBox*) = 0;
    301302    virtual bool setupFill(InlineBox*) = 0;
    302303    virtual bool setupStroke(InlineBox*) = 0;
     304    virtual bool setupForeground(InlineBox*) = 0;
    303305};
    304306
     
    316318    typedef void (CallbackClass::*SVGTextChunkEndCallback)(InlineBox* box);
    317319
     320    typedef bool (CallbackClass::*SVGTextChunkSetupBackgroundCallback)(InlineBox* box);
    318321    typedef bool (CallbackClass::*SVGTextChunkSetupFillCallback)(InlineBox* box);
    319322    typedef bool (CallbackClass::*SVGTextChunkSetupStrokeCallback)(InlineBox* box);
     323    typedef bool (CallbackClass::*SVGTextChunkSetupForegroundCallback)(InlineBox* box);
    320324
    321325    SVGTextChunkWalker(CallbackClass* object,
     
    323327                       SVGTextChunkStartCallback start = 0,
    324328                       SVGTextChunkEndCallback end = 0,
     329                       SVGTextChunkSetupBackgroundCallback background = 0,
    325330                       SVGTextChunkSetupFillCallback fill = 0,
    326                        SVGTextChunkSetupStrokeCallback stroke = 0)
     331                       SVGTextChunkSetupStrokeCallback stroke = 0,
     332                       SVGTextChunkSetupForegroundCallback foreground = 0)
    327333        : m_object(object)
    328334        , m_walkerCallback(walker)
    329335        , m_startCallback(start)
    330336        , m_endCallback(end)
     337        , m_setupBackgroundCallback(background)
    331338        , m_setupFillCallback(fill)
    332339        , m_setupStrokeCallback(stroke)
     340        , m_setupForegroundCallback(foreground)
    333341    {
    334342        ASSERT(object);
     
    359367    }
    360368
     369    virtual bool setupBackground(InlineBox* box)
     370    {
     371        if (m_setupBackgroundCallback)
     372            return (*m_object.*m_setupBackgroundCallback)(box);
     373
     374        ASSERT_NOT_REACHED();
     375        return false;
     376    }
     377
    361378    virtual bool setupFill(InlineBox* box)
    362379    {
     
    372389        if (m_setupStrokeCallback)
    373390            return (*m_object.*m_setupStrokeCallback)(box);
     391
     392        ASSERT_NOT_REACHED();
     393        return false;
     394    }
     395
     396    virtual bool setupForeground(InlineBox* box)
     397    {
     398        if (m_setupForegroundCallback)
     399            return (*m_object.*m_setupForegroundCallback)(box);
    374400
    375401        ASSERT_NOT_REACHED();
     
    382408    SVGTextChunkStartCallback m_startCallback;
    383409    SVGTextChunkEndCallback m_endCallback;
     410    SVGTextChunkSetupBackgroundCallback m_setupBackgroundCallback;
    384411    SVGTextChunkSetupFillCallback m_setupFillCallback;
    385412    SVGTextChunkSetupStrokeCallback m_setupStrokeCallback;
     413    SVGTextChunkSetupForegroundCallback m_setupForegroundCallback;
    386414};
    387415
  • trunk/WebCore/rendering/SVGInlineTextBox.cpp

    r50852 r52904  
    325325}
    326326
    327 void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int tx, int ty, const SVGChar& svgChar, const UChar* chars, int length, SVGPaintServer* activePaintServer)
     327void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int tx, int ty, const SVGChar& svgChar, const UChar* chars, int length, SVGTextPaintInfo& textPaintInfo)
    328328{
    329329    if (renderer()->style()->visibility() != VISIBLE || paintInfo.phase == PaintPhaseOutline)
     
    357357    // 1. Paint backgrounds behind text if needed.  Examples of such backgrounds include selection
    358358    // and marked text.
    359     if (paintInfo.phase != PaintPhaseSelection && !isPrinting) {
     359    if (paintInfo.phase != PaintPhaseSelection && !isPrinting && textPaintInfo.subphase == SVGTextPaintSubphaseBackground) {
    360360#if PLATFORM(MAC)
    361361        // Custom highlighters go behind everything else.
     
    377377    }
    378378
    379     // Set a text shadow if we have one.
    380     // FIXME: Support multiple shadow effects.  Need more from the CG API before
    381     // we can do this.
    382     bool setShadow = false;
    383     if (styleToUse->textShadow()) {
    384         paintInfo.context->setShadow(IntSize(styleToUse->textShadow()->x, styleToUse->textShadow()->y),
    385                                      styleToUse->textShadow()->blur, styleToUse->textShadow()->color,
    386                                      styleToUse->colorSpace());
    387         setShadow = true;
    388     }
    389 
    390     IntPoint origin((int) svgChar.x, (int) svgChar.y);
    391     TextRun run = svgTextRunForInlineTextBox(chars, length, styleToUse, this, svgChar.x);
     379    if  (textPaintInfo.subphase == SVGTextPaintSubphaseGlyphFill || textPaintInfo.subphase == SVGTextPaintSubphaseGlyphStroke) {
     380        // Set a text shadow if we have one.
     381        // FIXME: Support multiple shadow effects.  Need more from the CG API before
     382        // we can do this.
     383        bool setShadow = false;
     384        if (styleToUse->textShadow()) {
     385            paintInfo.context->setShadow(IntSize(styleToUse->textShadow()->x, styleToUse->textShadow()->y),
     386                                         styleToUse->textShadow()->blur, styleToUse->textShadow()->color,
     387                                         styleToUse->colorSpace());
     388            setShadow = true;
     389        }
     390
     391        IntPoint origin((int) svgChar.x, (int) svgChar.y);
     392        TextRun run = svgTextRunForInlineTextBox(chars, length, styleToUse, this, svgChar.x);
    392393
    393394#if ENABLE(SVG_FONTS)
    394     // SVG Fonts need access to the paint server used to draw the current text chunk.
    395     // They need to be able to call renderPath() on a SVGPaintServer object.
    396     run.setActivePaintServer(activePaintServer);
     395        // SVG Fonts need access to the paint server used to draw the current text chunk.
     396        // They need to be able to call renderPath() on a SVGPaintServer object.
     397        ASSERT(textPaintInfo.activePaintServer);
     398        run.setActivePaintServer(textPaintInfo.activePaintServer);
    397399#endif
    398400
    399     paintInfo.context->drawText(font, run, origin);
    400 
    401     if (paintInfo.phase != PaintPhaseSelection) {
     401        paintInfo.context->drawText(font, run, origin);
     402
     403        if (setShadow)
     404            paintInfo.context->clearShadow();
     405    }
     406
     407    if (paintInfo.phase != PaintPhaseSelection && textPaintInfo.subphase == SVGTextPaintSubphaseForeground) {
    402408        paintDocumentMarkers(paintInfo.context, tx, ty, styleToUse, font, false);
    403409
     
    429435    }
    430436
    431     if (setShadow)
    432         paintInfo.context->clearShadow();
    433 
    434437    if (!ctm.isIdentity())
    435438        paintInfo.context->concatCTM(ctm.inverse());
  • trunk/WebCore/rendering/SVGInlineTextBox.h

    r50583 r52904  
    3333    struct SVGTextDecorationInfo;
    3434
     35    enum SVGTextPaintSubphase {
     36        SVGTextPaintSubphaseBackground,
     37        SVGTextPaintSubphaseGlyphFill,
     38        SVGTextPaintSubphaseGlyphStroke,
     39        SVGTextPaintSubphaseForeground
     40    };
     41
     42    struct SVGTextPaintInfo {
     43        SVGTextPaintInfo() : activePaintServer(0), subphase(SVGTextPaintSubphaseBackground) {}
     44
     45        SVGPaintServer* activePaintServer;
     46        SVGTextPaintSubphase subphase;
     47    };
     48
    3549    class SVGInlineTextBox : public InlineTextBox {
    3650    public:
     
    5064
    5165        // SVGs custom paint text method
    52         void paintCharacters(RenderObject::PaintInfo&, int tx, int ty, const SVGChar&, const UChar* chars, int length, SVGPaintServer*);
     66        void paintCharacters(RenderObject::PaintInfo&, int tx, int ty, const SVGChar&, const UChar* chars, int length, SVGTextPaintInfo&);
    5367
    5468        // SVGs custom paint selection method
  • trunk/WebCore/rendering/SVGRootInlineBox.cpp

    r52584 r52904  
    430430    }
    431431
     432    bool chunkSetupBackgroundCallback(InlineBox* /*box*/)
     433    {
     434        m_textPaintInfo.subphase = SVGTextPaintSubphaseBackground;
     435        return true;
     436    }
     437
    432438    bool chunkSetupFillCallback(InlineBox* box)
    433439    {
     
    441447        teardownFillPaintServer();
    442448
     449        m_textPaintInfo.subphase = SVGTextPaintSubphaseGlyphFill;
    443450        m_fillPaintServer = SVGPaintServer::fillPaintServer(object->style(), object);
    444451        if (m_fillPaintServer) {
     
    463470        teardownStrokePaintServer();
    464471
     472        m_textPaintInfo.subphase = SVGTextPaintSubphaseGlyphStroke;
    465473        m_strokePaintServer = SVGPaintServer::strokePaintServer(object->style(), object);
    466474
     
    472480
    473481        return false;
     482    }
     483
     484    bool chunkSetupForegroundCallback(InlineBox* /*box*/)
     485    {
     486        teardownFillPaintServer();
     487        teardownStrokePaintServer();
     488
     489        m_textPaintInfo.subphase = SVGTextPaintSubphaseForeground;
     490
     491        return true;
     492    }
     493
     494    SVGPaintServer* activePaintServer() const
     495    {
     496        switch (m_textPaintInfo.subphase) {
     497        case SVGTextPaintSubphaseGlyphFill:
     498            ASSERT(m_fillPaintServer);
     499            return m_fillPaintServer;
     500        case SVGTextPaintSubphaseGlyphStroke:
     501            ASSERT(m_strokePaintServer);
     502            return m_strokePaintServer;
     503        case SVGTextPaintSubphaseBackground:
     504        case SVGTextPaintSubphaseForeground:
     505        default:
     506            return 0;
     507        }
    474508    }
    475509
     
    524558
    525559            // Paint text
    526             SVGPaintServer* activePaintServer = m_fillPaintServer;
    527             if (!activePaintServer)
    528                 activePaintServer = m_strokePaintServer;
    529 
    530             ASSERT(activePaintServer);
    531             textBox->paintCharacters(m_paintInfo, m_tx, m_ty, *it, stringStart, stringLength, activePaintServer);
     560            m_textPaintInfo.activePaintServer = activePaintServer();
     561            textBox->paintCharacters(m_paintInfo, m_tx, m_ty, *it, stringStart, stringLength, m_textPaintInfo);
    532562
    533563            // Paint decorations, that have to be drawn afterwards
     
    562592    int m_tx;
    563593    int m_ty;
     594
     595    SVGTextPaintInfo m_textPaintInfo;
    564596};
    565597
     
    583615                                                               &SVGRootInlineBoxPaintWalker::chunkStartCallback,
    584616                                                               &SVGRootInlineBoxPaintWalker::chunkEndCallback,
     617                                                               &SVGRootInlineBoxPaintWalker::chunkSetupBackgroundCallback,
    585618                                                               &SVGRootInlineBoxPaintWalker::chunkSetupFillCallback,
    586                                                                &SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback);
     619                                                               &SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback,
     620                                                               &SVGRootInlineBoxPaintWalker::chunkSetupForegroundCallback);
    587621
    588622        walkTextChunks(&walker);
     
    16811715                (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
    16821716            else {
     1717                if (walker->setupBackground(range.box))
     1718                    (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
     1719
    16831720                if (walker->setupFill(range.box))
    16841721                    (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
     
    16861723                if (walker->setupStroke(range.box))
    16871724                    (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
     1725
     1726                if (walker->setupForeground(range.box))
     1727                    (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
     1728
    16881729            }
    16891730
Note: See TracChangeset for help on using the changeset viewer.