Changeset 60689 in webkit


Ignore:
Timestamp:
Jun 4, 2010 11:02:13 AM (14 years ago)
Author:
krit@webkit.org
Message:

2010-06-04 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

SVG filter on filter don't work
https://bugs.webkit.org/show_bug.cgi?id=32708


Any child of <text> was not allowed to use the same filter as the text root.
I couldn't found any reason in the SVG specification that legimitate this.
Only batik also doesn't allow the same filter on the text root as on it's childs,
while any other effect is still allowed.
I removed this limitation so that the result looks like the result on Firefox.

Test: svg/filters/filter-on-filter-for-text.svg

  • rendering/SVGRenderSupport.cpp: (WebCore::SVGRenderBase::prepareToRenderSVGContent):
  • rendering/SVGRenderSupport.h:
  • rendering/SVGRootInlineBox.cpp: (WebCore::SVGRootInlineBoxPaintWalker::SVGRootInlineBoxPaintWalker): (WebCore::SVGRootInlineBoxPaintWalker::chunkStartCallback): (WebCore::SVGRootInlineBox::paint):

2010-06-04 Dirk Schulze <krit@webkit.org>

Reviewed by Nikolas Zimmermann.

SVG filter on filter don't work
https://bugs.webkit.org/show_bug.cgi?id=32708


Test that a filter can be used by the text root as well as on it's childs.

  • platform/mac/svg/filters/filter-on-filter-for-text-expected.checksum: Added.
  • platform/mac/svg/filters/filter-on-filter-for-text-expected.png: Added.
  • platform/mac/svg/filters/filter-on-filter-for-text-expected.txt: Added.
  • svg/filters/filter-on-filter-for-text.svg: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r60685 r60689  
     12010-06-04  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVG filter on filter don't work
     6        https://bugs.webkit.org/show_bug.cgi?id=32708
     7       
     8        Test that a filter can be used by the text root as well as on it's childs.
     9
     10        * platform/mac/svg/filters/filter-on-filter-for-text-expected.checksum: Added.
     11        * platform/mac/svg/filters/filter-on-filter-for-text-expected.png: Added.
     12        * platform/mac/svg/filters/filter-on-filter-for-text-expected.txt: Added.
     13        * svg/filters/filter-on-filter-for-text.svg: Added.
     14
    1152010-06-04  Alexey Proskuryakov  <ap@apple.com>
    216
  • trunk/WebCore/ChangeLog

    r60688 r60689  
     12010-06-04  Dirk Schulze  <krit@webkit.org>
     2
     3        Reviewed by Nikolas Zimmermann.
     4
     5        SVG filter on filter don't work
     6        https://bugs.webkit.org/show_bug.cgi?id=32708
     7       
     8        Any child of <text> was not allowed to use the same filter as the text root.
     9        I couldn't found any reason in the SVG specification that legimitate this.
     10        Only batik also doesn't allow the same filter on the text root as on it's childs,
     11        while any other effect is still allowed.
     12        I removed this limitation so that the result looks like the result on Firefox.
     13
     14        Test: svg/filters/filter-on-filter-for-text.svg
     15
     16        * rendering/SVGRenderSupport.cpp:
     17        (WebCore::SVGRenderBase::prepareToRenderSVGContent):
     18        * rendering/SVGRenderSupport.h:
     19        * rendering/SVGRootInlineBox.cpp:
     20        (WebCore::SVGRootInlineBoxPaintWalker::SVGRootInlineBoxPaintWalker):
     21        (WebCore::SVGRootInlineBoxPaintWalker::chunkStartCallback):
     22        (WebCore::SVGRootInlineBox::paint):
     23
    1242010-06-04  Nate Chapin  <japhet@chromium.org>
    225
  • trunk/WebCore/rendering/SVGRenderSupport.cpp

    r60541 r60689  
    8282}
    8383
    84 bool SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& repaintRect, RenderSVGResourceFilter*& filter, RenderSVGResourceFilter* rootFilter)
     84bool SVGRenderBase::prepareToRenderSVGContent(RenderObject* object, RenderObject::PaintInfo& paintInfo, const FloatRect& repaintRect, RenderSVGResourceFilter*& filter)
    8585{
    8686#if !ENABLE(FILTERS)
     
    100100    ASSERT(svgStyle);
    101101
    102     // Setup transparency layers before setting up filters!
     102    // Setup transparency layers before setting up SVG resources!
    103103    float opacity = style->opacity();
    104104    if (opacity < 1.0f) {
     
    113113    }
    114114
     115    Document* document = object->document();
     116
     117    if (svgStyle->hasMasker()) {
     118        AtomicString maskerId(svgStyle->maskerResource());
     119        if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(document, maskerId)) {
     120            if (!masker->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
     121                return false;
     122        } else
     123            svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
     124    }
     125
     126    if (svgStyle->hasClipper()) {
     127        AtomicString clipperId(svgStyle->clipperResource());
     128        if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(document, clipperId))
     129            clipper->applyResource(object, style, paintInfo.context, ApplyToDefaultMode);
     130        else
     131            svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
     132    }
     133
    115134#if ENABLE(FILTERS)
    116     AtomicString filterId(svgStyle->filterResource());
    117 #endif
    118 
    119     AtomicString clipperId(svgStyle->clipperResource());
    120     AtomicString maskerId(svgStyle->maskerResource());
    121 
    122     Document* document = object->document();
    123 
    124 #if ENABLE(FILTERS)
    125     RenderSVGResourceFilter* newFilter = getRenderSVGResourceById<RenderSVGResourceFilter>(document, filterId);
    126     if (newFilter == rootFilter) {
    127         // Catch <text filter="url(#foo)">Test<tspan filter="url(#foo)">123</tspan></text>.
    128         // The filter is NOT meant to be applied twice in that case!
    129         filter = 0;
    130         filterId = String();
    131     } else
    132         filter = newFilter;
    133 #endif
    134 
    135     if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(document, maskerId)) {
    136         if (!masker->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
    137             return false;
    138     } else if (!maskerId.isEmpty())
    139         svgElement->document()->accessSVGExtensions()->addPendingResource(maskerId, styledElement);
    140 
    141     if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(document, clipperId))
    142         clipper->applyResource(object, style, paintInfo.context, ApplyToDefaultMode);
    143     else if (!clipperId.isEmpty())
    144         svgElement->document()->accessSVGExtensions()->addPendingResource(clipperId, styledElement);
    145 
    146 #if ENABLE(FILTERS)
    147     if (filter) {
    148         if (!filter->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
    149             return false;
    150     } else if (!filterId.isEmpty())
    151         svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
     135    if (svgStyle->hasFilter()) {
     136        AtomicString filterId(svgStyle->filterResource());
     137        filter = getRenderSVGResourceById<RenderSVGResourceFilter>(document, filterId);
     138        if (filter) {
     139            if (!filter->applyResource(object, style, paintInfo.context, ApplyToDefaultMode))
     140                return false;
     141        } else
     142            svgElement->document()->accessSVGExtensions()->addPendingResource(filterId, styledElement);
     143    }
    152144#endif
    153145
  • trunk/WebCore/rendering/SVGRenderSupport.h

    r60541 r60689  
    4747    // It's unclear if these should be exposed or not.  SVGRootInlineBox may
    4848    // pass the wrong RenderObject* and boundingBox to these functions.
    49     static bool prepareToRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, const FloatRect& boundingBox, RenderSVGResourceFilter*&, RenderSVGResourceFilter* rootFilter = 0);
     49    static bool prepareToRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, const FloatRect& boundingBox, RenderSVGResourceFilter*&);
    5050    static void finishRenderSVGContent(RenderObject*, RenderObject::PaintInfo&, RenderSVGResourceFilter*&, GraphicsContext* savedContext);
    5151
  • trunk/WebCore/rendering/SVGRootInlineBox.cpp

    r59589 r60689  
    7474// Helper class for paint()
    7575struct SVGRootInlineBoxPaintWalker {
    76     SVGRootInlineBoxPaintWalker(SVGRootInlineBox* rootBox, RenderSVGResourceFilter* rootFilter, RenderObject::PaintInfo paintInfo, int tx, int ty)
     76    SVGRootInlineBoxPaintWalker(SVGRootInlineBox* rootBox, RenderObject::PaintInfo paintInfo, int tx, int ty)
    7777        : m_rootBox(rootBox)
    7878        , m_chunkStarted(false)
     
    8181        , m_boundingBox(tx + rootBox->x(), ty + rootBox->y(), rootBox->width(), rootBox->height())
    8282        , m_filter(0)
    83         , m_rootFilter(rootFilter)
    8483        , m_fillPaintingResource(0)
    8584        , m_strokePaintingResource(0)
     
    144143        // FIXME: Why is this done here instead of in RenderSVGText?
    145144        if (!flowBox->isRootInlineBox())
    146             SVGRenderBase::prepareToRenderSVGContent(object, m_paintInfo, m_boundingBox, m_filter, m_rootFilter);
     145            SVGRenderBase::prepareToRenderSVGContent(object, m_paintInfo, m_boundingBox, m_filter);
    147146    }
    148147
     
    404403    FloatRect m_boundingBox;
    405404    RenderSVGResourceFilter* m_filter;
    406     RenderSVGResourceFilter* m_rootFilter;
    407405
    408406    RenderSVGResource* m_fillPaintingResource;
     
    432430    if (SVGRenderBase::prepareToRenderSVGContent(renderer(), paintInfo, boundingBox, filter)) {
    433431        // Render text, chunk-by-chunk
    434         SVGRootInlineBoxPaintWalker walkerCallback(this, filter, paintInfo, tx, ty);
     432        SVGRootInlineBoxPaintWalker walkerCallback(this, paintInfo, tx, ty);
    435433        SVGTextChunkWalker<SVGRootInlineBoxPaintWalker> walker(&walkerCallback,
    436434                                                               &SVGRootInlineBoxPaintWalker::chunkPortionCallback,
Note: See TracChangeset for help on using the changeset viewer.