Changeset 138823 in webkit


Ignore:
Timestamp:
Jan 4, 2013 11:48:10 AM (11 years ago)
Author:
senorblanco@chromium.org
Message:

CSS url() filters with forward references don't work
https://bugs.webkit.org/show_bug.cgi?id=90405

Based on a patch by Keyar Hood.

Reviewed by Dirk Schulze.

Source/WebCore:

In order for CSS to reference SVG filters that will occur later in
the document, or will be added at a future time, we need a way to
notify the target element (the one the filter style is applied to)
when the correct SVG filter is added to the DOM.
There is already code for SVG elements that handles this problem, in
SVGResourcesCache. This patch allows any element to have a reference to
an SVG element in SVGResourceCache.

Tests: css3/filters/effect-reference-after.html

css3/filters/effect-reference-delete-crash.html
css3/filters/effect-reference-delete.html
css3/filters/effect-reference-removed-while-pending-resources.html
css3/filters/effect-reference-rename.html
css3/filters/effect-reference-reset-style-delete-crash.html
svg/filters/filter-cycle.html

  • dom/Element.cpp:

(WebCore::Element::~Element):
(WebCore::Element::removedFrom):
When an Element is deleted or removed from its container, and it
has pending resources, remove it from the SVGResourceCache resources
on deletion or when removed from its container.
(WebCore::Element::hasPendingResources):
(WebCore::Element::setHasPendingResources):
(WebCore::Element::clearHasPendingResources):
Accessors for ElementRareData's new bit flag.

  • dom/Element.h:

(WebCore::Element::buildPendingResource):
Virtual function to override for referenced elements (moved from SVGElement).

  • dom/ElementRareData.h:

(WebCore::ElementRareData::hasPendingResources):
(WebCore::ElementRareData::setHasPendingResources):
(WebCore::ElementRareData::ElementRareData):
Add a new bit flag to indicate whether the element depends on pending resources or not, and accessors.

  • dom/NodeRareData.h:

(WebCore::NodeRareData::NodeRareData):
(NodeRareData):
The actual flag bit lives in NodeRareData, so it compacts better with
other flags.

  • platform/graphics/texmap/TextureMapperImageBuffer.cpp:

(WebCore::BitmapTextureImageBuffer::applyFilters):
Changed to the new function signature for FilterEffectRenderer::build().

  • rendering/FilterEffectRenderer.cpp:

(WebCore::createCustomFilterEffect):
(WebCore::FilterEffectRenderer::buildReferenceFilter):
Changed signature to accept a RenderObject rather than a Document, so we know which node to notify when the SVG filter arrives. If the referenced filter cannot be found, add its id as a pending reference.
(WebCore::FilterEffectRenderer::build):

  • rendering/FilterEffectRenderer.h:

Change to signatures of build() and buildReferenceFilter() to pass

  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::updateOrRemoveFilterEffectRenderer):
Use the new semantics for FilterEffectRenderer::build().

  • rendering/svg/RenderSVGResourceContainer.cpp:

(WebCore::RenderSVGResourceContainer::registerResource):
Call clearHasPendingResourceIfPossible on the SVGDocumentExtensions, not
on the element, since we want to support generic Elements.

  • rendering/svg/SVGResourcesCache.cpp:

(WebCore::SVGResourcesCache::addResourcesFromRenderObject):
(WebCore::SVGResourcesCache::clientStyleChanged):
For non-SVG elements, set a synthetic style change when parent resources
are invalidated.
(WebCore::SVGResourcesCache::resourceDestroyed):
Add support for non-SVG Elements.

  • svg/SVGDocumentExtensions.cpp:

(WebCore::SVGDocumentExtensions::addPendingResource):
(WebCore::SVGDocumentExtensions::isElementPendingResources):
(WebCore::SVGDocumentExtensions::isElementPendingResource):
Changed to allow use of Element instead of SVGElement.
(WebCore::SVGDocumentExtensions::clearHasPendingResourcesIfPossible):
Moved from SVGElement, and made to work on any Element. This way,
we avoid adding this function to Element itself.
(WebCore::SVGDocumentExtensions::removeElementFromPendingResources):
(WebCore::SVGDocumentExtensions::removeElementFromPendingResourcesForRemoval):
Changed to allow use of Element instead of SVGElement.

  • svg/SVGDocumentExtensions.h:

SVGElement -> Element.

  • svg/SVGElement.cpp:

(WebCore::SVGElement::~SVGElement):
(WebCore::SVGElement::removedFrom):
Don't handle pending resource notifications (Element will do it).

  • svg/SVGElement.h:

All functions moved to Element, except for clearHasPendingResourcesIfPossible() moved to SVGDocumentExtensions.

  • svg/SVGElementRareData.h:

(WebCore::SVGElementRareData::SVGElementRareData):
m_hasPendingResources and accessors moved to ElementRareData.

  • svg/SVGStyledElement.cpp:

(WebCore::SVGStyledElement::buildPendingResourcesIfNeeded):
SVGElement -> Element, and call SVGDocumentExtensions for
clearHasPendingResourcesIfPossible().

LayoutTests:

  • css3/filters/effect-reference-after-expected.html: Added.
  • css3/filters/effect-reference-after.html: Added.
  • css3/filters/effect-reference-delete-crash.html: Added.
  • css3/filters/effect-reference-delete-expected.html: Added.
  • css3/filters/effect-reference-delete.html: Added.
  • css3/filters/effect-reference-removed-while-pending-resources-expected.html: Added.
  • css3/filters/effect-reference-removed-while-pending-resources.html: Added.
  • css3/filters/effect-reference-rename-expected.html: Added.
  • css3/filters/effect-reference-rename.html: Added.
  • css3/filters/effect-reference-reset-style-delete-crash-expected.txt: Added.
  • css3/filters/effect-reference-reset-style-delete-crash.html: Added.
  • css3/filters/script-tests/effect-reference-delete-crash.js: Added.
  • css3/filters/script-tests/effect-reference-reset-style-delete-crash.js: Added.
  • svg/filters/filter-cycle-expected.html: Added.
  • svg/filters/filter-cycle.html: Added.
Location:
trunk
Files:
16 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r138820 r138823  
     12013-01-04  Stephen White  <senorblanco@chromium.org>
     2
     3        CSS url() filters with forward references don't work
     4        https://bugs.webkit.org/show_bug.cgi?id=90405
     5
     6        Based on a patch by Keyar Hood.
     7
     8        Reviewed by Dirk Schulze.
     9
     10        * css3/filters/effect-reference-after-expected.html: Added.
     11        * css3/filters/effect-reference-after.html: Added.
     12        * css3/filters/effect-reference-delete-crash.html: Added.
     13        * css3/filters/effect-reference-delete-expected.html: Added.
     14        * css3/filters/effect-reference-delete.html: Added.
     15        * css3/filters/effect-reference-removed-while-pending-resources-expected.html: Added.
     16        * css3/filters/effect-reference-removed-while-pending-resources.html: Added.
     17        * css3/filters/effect-reference-rename-expected.html: Added.
     18        * css3/filters/effect-reference-rename.html: Added.
     19        * css3/filters/effect-reference-reset-style-delete-crash-expected.txt: Added.
     20        * css3/filters/effect-reference-reset-style-delete-crash.html: Added.
     21        * css3/filters/script-tests/effect-reference-delete-crash.js: Added.
     22        * css3/filters/script-tests/effect-reference-reset-style-delete-crash.js: Added.
     23        * svg/filters/filter-cycle-expected.html: Added.
     24        * svg/filters/filter-cycle.html: Added.
     25
    1262013-01-04  Mike West  <mkwst@chromium.org>
    227
  • trunk/Source/WebCore/ChangeLog

    r138821 r138823  
     12013-01-04  Stephen White  <senorblanco@chromium.org>
     2
     3        CSS url() filters with forward references don't work
     4        https://bugs.webkit.org/show_bug.cgi?id=90405
     5
     6        Based on a patch by Keyar Hood.
     7
     8        Reviewed by Dirk Schulze.
     9
     10        In order for CSS to reference SVG filters that will occur later in
     11        the document, or will be added at a future time, we need a way to
     12        notify the target element (the one the filter style is applied to)
     13        when the correct SVG filter is added to the DOM.
     14        There is already code for SVG elements that handles this problem, in
     15        SVGResourcesCache. This patch allows any element to have a reference to
     16        an SVG element in SVGResourceCache.
     17
     18        Tests: css3/filters/effect-reference-after.html
     19               css3/filters/effect-reference-delete-crash.html
     20               css3/filters/effect-reference-delete.html
     21               css3/filters/effect-reference-removed-while-pending-resources.html
     22               css3/filters/effect-reference-rename.html
     23               css3/filters/effect-reference-reset-style-delete-crash.html
     24               svg/filters/filter-cycle.html
     25
     26        * dom/Element.cpp:
     27        (WebCore::Element::~Element):
     28        (WebCore::Element::removedFrom):
     29        When an Element is deleted or removed from its container, and it
     30        has pending resources, remove it from the SVGResourceCache resources
     31        on deletion or when removed from its container.
     32        (WebCore::Element::hasPendingResources):
     33        (WebCore::Element::setHasPendingResources):
     34        (WebCore::Element::clearHasPendingResources):
     35        Accessors for ElementRareData's new bit flag.
     36        * dom/Element.h:
     37        (WebCore::Element::buildPendingResource):
     38        Virtual function to override for referenced elements (moved from SVGElement).
     39        * dom/ElementRareData.h:
     40        (WebCore::ElementRareData::hasPendingResources):
     41        (WebCore::ElementRareData::setHasPendingResources):
     42        (WebCore::ElementRareData::ElementRareData):
     43        Add a new bit flag to indicate whether the element depends on pending resources or not, and accessors.
     44        * dom/NodeRareData.h:
     45        (WebCore::NodeRareData::NodeRareData):
     46        (NodeRareData):
     47        The actual flag bit lives in NodeRareData, so it compacts better with
     48        other flags.
     49        * platform/graphics/texmap/TextureMapperImageBuffer.cpp:
     50        (WebCore::BitmapTextureImageBuffer::applyFilters):
     51        Changed to the new function signature for FilterEffectRenderer::build().
     52        * rendering/FilterEffectRenderer.cpp:
     53        (WebCore::createCustomFilterEffect):
     54        (WebCore::FilterEffectRenderer::buildReferenceFilter):
     55        Changed signature to accept a RenderObject rather than a Document, so we know which node to notify when the SVG filter arrives.  If the referenced filter cannot be found, add its id as a pending reference.
     56        (WebCore::FilterEffectRenderer::build):
     57        * rendering/FilterEffectRenderer.h:
     58        Change to signatures of build() and buildReferenceFilter() to pass
     59        * rendering/RenderLayer.cpp:
     60        (WebCore::RenderLayer::updateOrRemoveFilterEffectRenderer):
     61        Use the new semantics for FilterEffectRenderer::build().
     62        * rendering/svg/RenderSVGResourceContainer.cpp:
     63        (WebCore::RenderSVGResourceContainer::registerResource):
     64        Call clearHasPendingResourceIfPossible on the SVGDocumentExtensions, not
     65        on the element, since we want to support generic Elements.
     66        * rendering/svg/SVGResourcesCache.cpp:
     67        (WebCore::SVGResourcesCache::addResourcesFromRenderObject):
     68        (WebCore::SVGResourcesCache::clientStyleChanged):
     69        For non-SVG elements, set a synthetic style change when parent resources
     70        are invalidated.
     71        (WebCore::SVGResourcesCache::resourceDestroyed):
     72        Add support for non-SVG Elements.
     73        * svg/SVGDocumentExtensions.cpp:
     74        (WebCore::SVGDocumentExtensions::addPendingResource):
     75        (WebCore::SVGDocumentExtensions::isElementPendingResources):
     76        (WebCore::SVGDocumentExtensions::isElementPendingResource):
     77        Changed to allow use of Element instead of SVGElement.
     78        (WebCore::SVGDocumentExtensions::clearHasPendingResourcesIfPossible):
     79        Moved from SVGElement, and made to work on any Element.  This way,
     80        we avoid adding this function to Element itself.
     81        (WebCore::SVGDocumentExtensions::removeElementFromPendingResources):
     82        (WebCore::SVGDocumentExtensions::removeElementFromPendingResourcesForRemoval):
     83        Changed to allow use of Element instead of SVGElement.
     84        * svg/SVGDocumentExtensions.h:
     85        SVGElement -> Element.
     86        * svg/SVGElement.cpp:
     87        (WebCore::SVGElement::~SVGElement):
     88        (WebCore::SVGElement::removedFrom):
     89        Don't handle pending resource notifications (Element will do it).
     90        * svg/SVGElement.h:
     91        All functions moved to Element, except for clearHasPendingResourcesIfPossible() moved to SVGDocumentExtensions.
     92        * svg/SVGElementRareData.h:
     93        (WebCore::SVGElementRareData::SVGElementRareData):
     94        m_hasPendingResources and accessors moved to ElementRareData.
     95        * svg/SVGStyledElement.cpp:
     96        (WebCore::SVGStyledElement::buildPendingResourcesIfNeeded):
     97        SVGElement -> Element, and call SVGDocumentExtensions for
     98        clearHasPendingResourcesIfPossible().
     99
    11002013-01-04  John Mellor  <johnme@chromium.org>
    2101
  • trunk/Source/WebCore/dom/Element.cpp

    r138811 r138823  
    8585
    8686#if ENABLE(SVG)
     87#include "SVGDocumentExtensions.h"
    8788#include "SVGElement.h"
    8889#include "SVGNames.h"
     
    203204    if (hasSyntheticAttrChildNodes())
    204205        detachAllAttrNodesFromElement();
     206
     207#if ENABLE(SVG)
     208    if (hasPendingResources()) {
     209        document()->accessSVGExtensions()->removeElementFromPendingResources(this);
     210        ASSERT(!hasPendingResources());
     211    }
     212#endif
    205213}
    206214
     
    11271135void Element::removedFrom(ContainerNode* insertionPoint)
    11281136{
     1137#if ENABLE(SVG)
     1138    bool wasInDocument = insertionPoint->document();
     1139#endif
     1140
    11291141#if ENABLE(DIALOG_ELEMENT)
    11301142    setIsInTopLayer(false);
     
    11581170
    11591171    ContainerNode::removedFrom(insertionPoint);
     1172#if ENABLE(SVG)
     1173    if (wasInDocument && hasPendingResources())
     1174        document()->accessSVGExtensions()->removeElementFromPendingResources(this);
     1175#endif
    11601176}
    11611177
     
    27162732}
    27172733
     2734#if ENABLE(SVG)
     2735bool Element::hasPendingResources() const
     2736{
     2737    return hasRareData() && elementRareData()->hasPendingResources();
     2738}
     2739
     2740void Element::setHasPendingResources()
     2741{
     2742    ensureElementRareData()->setHasPendingResources(true);
     2743}
     2744
     2745void Element::clearHasPendingResources()
     2746{
     2747    ensureElementRareData()->setHasPendingResources(false);
     2748}
     2749#endif
     2750
    27182751} // namespace WebCore
  • trunk/Source/WebCore/dom/Element.h

    r138784 r138823  
    430430#if ENABLE(SVG)
    431431    virtual bool childShouldCreateRenderer(const NodeRenderingContext&) const;
     432    bool hasPendingResources() const;
     433    void setHasPendingResources();
     434    void clearHasPendingResources();
     435    virtual void buildPendingResource() { };
    432436#endif
    433437
  • trunk/Source/WebCore/dom/ElementRareData.h

    r138784 r138823  
    120120    void setSavedLayerScrollOffset(IntSize size) { m_savedLayerScrollOffset = size; }
    121121
     122#if ENABLE(SVG)
     123    bool hasPendingResources() const { return m_hasPendingResources; }
     124    void setHasPendingResources(bool has) { m_hasPendingResources = has; }
     125#endif
     126
    122127private:
    123128    // Many fields are in NodeRareData for better packing.
  • trunk/Source/WebCore/dom/NodeRareData.h

    r138811 r138823  
    261261        , m_isInTopLayer(false)
    262262#endif
     263#if ENABLE(SVG)
     264        , m_hasPendingResources(false)
     265#endif
    263266        , m_childrenAffectedByHover(false)
    264267        , m_childrenAffectedByActive(false)
     
    386389#if ENABLE(DIALOG_ELEMENT)
    387390    bool m_isInTopLayer : 1;
     391#endif
     392#if ENABLE(SVG)
     393    bool m_hasPendingResources : 1;
    388394#endif
    389395    bool m_childrenAffectedByHover : 1;
  • trunk/Source/WebCore/platform/graphics/texmap/TextureMapperImageBuffer.cpp

    r137555 r138823  
    171171    renderer->setSourceImageRect(FloatRect(FloatPoint::zero(), contentTexture.size()));
    172172
    173     // The document parameter is only needed for CSS shaders.
    174     renderer->build(0 /*document */, filters);
     173    // The renderer parameter is only needed for CSS shaders and reference filters.
     174    renderer->build(0 /*renderer */, filters);
    175175    renderer->allocateBackingStoreIfNeeded();
    176176    GraphicsContext* context = renderer->inputContext();
  • trunk/Source/WebCore/rendering/FilterEffectRenderer.cpp

    r138250 r138823  
    8989static PassRefPtr<FECustomFilter> createCustomFilterEffect(Filter* filter, Document* document, ValidatedCustomFilterOperation* operation)
    9090{
     91    if (!document)
     92        return 0;
     93
    9194    CustomFilterGlobalContext* globalContext = document->renderView()->customFilterGlobalContext();
    9295    globalContext->prepareContextIfNeeded(document->view()->hostWindow());
     
    123126}
    124127
    125 PassRefPtr<FilterEffect> FilterEffectRenderer::buildReferenceFilter(Document* document, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation* filterOperation)
     128PassRefPtr<FilterEffect> FilterEffectRenderer::buildReferenceFilter(RenderObject* renderer, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation* filterOperation)
    126129{
    127130#if ENABLE(SVG)
     131    if (!renderer)
     132        return 0;
     133
     134    Document* document = renderer->document();
     135    ASSERT(document);
     136
    128137    CachedSVGDocumentReference* cachedSVGDocumentReference = filterOperation->cachedSVGDocumentReference();
    129138    CachedSVGDocument* cachedSVGDocument = cachedSVGDocumentReference ? cachedSVGDocumentReference->document() : 0;
     
    138147
    139148    Element* filter = document->getElementById(filterOperation->fragment());
    140     if (!filter)
     149    if (!filter) {
     150        // Although we did not find the referenced filter, it might exist later
     151        // in the document
     152        document->accessSVGExtensions()->addPendingResource(filterOperation->fragment(), toElement(renderer->node()));
    141153        return 0;
     154    }
    142155
    143156    RefPtr<FilterEffect> effect;
     
    176189}
    177190
    178 bool FilterEffectRenderer::build(Document* document, const FilterOperations& operations)
    179 {
    180 #if !ENABLE(CSS_SHADERS) || !USE(3D_GRAPHICS)
    181     UNUSED_PARAM(document);
    182 #endif
    183 
     191bool FilterEffectRenderer::build(RenderObject* renderer, const FilterOperations& operations)
     192{
    184193#if ENABLE(CSS_SHADERS)
    185194    m_hasCustomShaderFilter = false;
     
    201210        case FilterOperation::REFERENCE: {
    202211            ReferenceFilterOperation* referenceOperation = static_cast<ReferenceFilterOperation*>(filterOperation);
    203             effect = buildReferenceFilter(document, previousEffect, referenceOperation);
     212            effect = buildReferenceFilter(renderer, previousEffect, referenceOperation);
    204213            referenceOperation->setFilterEffect(effect);
    205214            break;
     
    344353        case FilterOperation::VALIDATED_CUSTOM: {
    345354            ValidatedCustomFilterOperation* customFilterOperation = static_cast<ValidatedCustomFilterOperation*>(filterOperation);
     355            Document* document = renderer ? renderer->document() : 0;
    346356            effect = createCustomFilterEffect(this, document, customFilterOperation);
    347357            if (effect)
  • trunk/Source/WebCore/rendering/FilterEffectRenderer.h

    r137463 r138823  
    102102    ImageBuffer* output() const { return lastEffect()->asImageBuffer(); }
    103103
    104     bool build(Document*, const FilterOperations&);
    105     PassRefPtr<FilterEffect> buildReferenceFilter(Document*, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation*);
     104    bool build(RenderObject* renderer, const FilterOperations&);
     105    PassRefPtr<FilterEffect> buildReferenceFilter(RenderObject* renderer, PassRefPtr<FilterEffect> previousEffect, ReferenceFilterOperation*);
    106106    bool updateBackingStoreRect(const FloatRect& filterRect);
    107107    void allocateBackingStoreIfNeeded();
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r138809 r138823  
    57495749    // If the filter fails to build, remove it from the layer. It will still attempt to
    57505750    // go through regular processing (e.g. compositing), but never apply anything.
    5751     if (!filterInfo->renderer()->build(renderer()->document(), computeFilterOperations(renderer()->style())))
     5751    if (!filterInfo->renderer()->build(renderer(), computeFilterOperations(renderer()->style())))
    57525752        filterInfo->setRenderer(0);
    57535753}
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp

    r137463 r138823  
    185185    for (SVGDocumentExtensions::SVGPendingElements::const_iterator it = clients->begin(); it != end; ++it) {
    186186        ASSERT((*it)->hasPendingResources());
    187         (*it)->clearHasPendingResourcesIfPossible();
     187        extensions->clearHasPendingResourcesIfPossible(*it);
    188188        RenderObject* renderer = (*it)->renderer();
    189189        if (!renderer)
  • trunk/Source/WebCore/rendering/svg/SVGResourcesCache.cpp

    r137463 r138823  
    126126}
    127127
     128static inline bool rendererCanHaveResources(RenderObject* renderer)
     129{
     130    ASSERT(renderer);
     131    return renderer->node() && renderer->node()->isSVGElement() && !renderer->isSVGInlineText();
     132}
     133
    128134void SVGResourcesCache::clientStyleChanged(RenderObject* renderer, StyleDifference diff, const RenderStyle* newStyle)
    129135{
     
    139145    // FIXME: Avoid passing in a useless StyleDifference, but instead compare oldStyle/newStyle to see which resources changed
    140146    // to be able to selectively rebuild individual resources, instead of all of them.
    141     SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer);
    142     cache->removeResourcesFromRenderObject(renderer);
    143     cache->addResourcesFromRenderObject(renderer, newStyle);
     147    if (rendererCanHaveResources(renderer)) {
     148        SVGResourcesCache* cache = resourcesCacheFromRenderObject(renderer);
     149        cache->removeResourcesFromRenderObject(renderer);
     150        cache->addResourcesFromRenderObject(renderer, newStyle);
     151    }
    144152
    145153    RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, false);
    146 }
    147 
    148 static inline bool rendererCanHaveResources(RenderObject* renderer)
    149 {
    150     ASSERT(renderer);
    151     ASSERT(renderer->parent());
    152     return renderer->node() && !renderer->isSVGInlineText();
     154
     155    if (renderer->node() && !renderer->node()->isSVGElement())
     156        renderer->node()->setNeedsStyleRecalc(SyntheticStyleChange);
    153157}
    154158
     
    203207        // Mark users of destroyed resources as pending resolution based on the id of the old resource.
    204208        Element* resourceElement = toElement(resource->node());
    205         SVGStyledElement* clientElement = toSVGStyledElement(it->key->node());
     209        Element* clientElement = toElement(it->key->node());
    206210        SVGDocumentExtensions* extensions = clientElement->document()->accessSVGExtensions();
    207211
  • trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp

    r137509 r138823  
    149149}
    150150
    151 void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGElement* element)
     151void SVGDocumentExtensions::addPendingResource(const AtomicString& id, Element* element)
    152152{
    153153    ASSERT(element);
     
    176176}
    177177
    178 bool SVGDocumentExtensions::isElementPendingResources(SVGElement* element) const
     178bool SVGDocumentExtensions::isElementPendingResources(Element* element) const
    179179{
    180180    // This algorithm takes time proportional to the number of pending resources and need not.
     
    194194}
    195195
    196 bool SVGDocumentExtensions::isElementPendingResource(SVGElement* element, const AtomicString& id) const
     196bool SVGDocumentExtensions::isElementPendingResource(Element* element, const AtomicString& id) const
    197197{
    198198    ASSERT(element);
     
    204204}
    205205
    206 void SVGDocumentExtensions::removeElementFromPendingResources(SVGElement* element)
     206void SVGDocumentExtensions::clearHasPendingResourcesIfPossible(Element* element)
     207{
     208    if (!isElementPendingResources(element))
     209        element->clearHasPendingResources();
     210}
     211
     212void SVGDocumentExtensions::removeElementFromPendingResources(Element* element)
    207213{
    208214    ASSERT(element);
     
    222228        }
    223229
    224         element->clearHasPendingResourcesIfPossible();
     230        clearHasPendingResourcesIfPossible(element);
    225231
    226232        // We use the removePendingResource function here because it deals with set lifetime correctly.
     
    275281}
    276282
    277 SVGElement* SVGDocumentExtensions::removeElementFromPendingResourcesForRemoval(const AtomicString& id)
     283Element* SVGDocumentExtensions::removeElementFromPendingResourcesForRemoval(const AtomicString& id)
    278284{
    279285    if (id.isEmpty())
     
    285291
    286292    SVGPendingElements::iterator firstElement = resourceSet->begin();
    287     SVGElement* element = *firstElement;
     293    Element* element = *firstElement;
    288294
    289295    resourceSet->remove(firstElement);
  • trunk/Source/WebCore/svg/SVGDocumentExtensions.h

    r137509 r138823  
    4141class SVGSMILElement;
    4242class SVGSVGElement;
     43class Element;
    4344
    4445class SVGDocumentExtensions {
    4546    WTF_MAKE_NONCOPYABLE(SVGDocumentExtensions); WTF_MAKE_FAST_ALLOCATED;
    4647public:
    47     typedef HashSet<SVGElement*> SVGPendingElements;
     48    typedef HashSet<Element*> SVGPendingElements;
    4849    SVGDocumentExtensions(Document*);
    4950    ~SVGDocumentExtensions();
     
    9394    // This HashMap contains a list of pending resources. Pending resources, are such
    9495    // which are referenced by any object in the SVG document, but do NOT exist yet.
    95     // For instance, dynamically built gradients / patterns / clippers...
    96     void addPendingResource(const AtomicString& id, SVGElement*);
     96    // For instance, dynamically build gradients / patterns / clippers...
     97    void addPendingResource(const AtomicString& id, Element*);
    9798    bool hasPendingResource(const AtomicString& id) const;
    98     bool isElementPendingResources(SVGElement*) const;
    99     bool isElementPendingResource(SVGElement*, const AtomicString& id) const;
    100     void removeElementFromPendingResources(SVGElement*);
     99    bool isElementPendingResources(Element*) const;
     100    bool isElementPendingResource(Element*, const AtomicString& id) const;
     101    void clearHasPendingResourcesIfPossible(Element*);
     102    void removeElementFromPendingResources(Element*);
    101103    PassOwnPtr<SVGPendingElements> removePendingResource(const AtomicString& id);
    102104
    103105    // The following two functions are used for scheduling a pending resource to be removed.
    104106    void markPendingResourcesForRemoval(const AtomicString&);
    105     SVGElement* removeElementFromPendingResourcesForRemoval(const AtomicString&);
     107    Element* removeElementFromPendingResourcesForRemoval(const AtomicString&);
    106108
    107109private:
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r138296 r138823  
    6666    else {
    6767        ASSERT(document());
    68         if (hasPendingResources())
    69             document()->accessSVGExtensions()->removeElementFromPendingResources(this);
    70         ASSERT(!hasPendingResources());
    7168        SVGElementRareData::SVGElementRareDataMap& rareDataMap = SVGElementRareData::rareDataMap();
    7269        SVGElementRareData::SVGElementRareDataMap::iterator it = rareDataMap.find(this);
     
    186183        document()->accessSVGExtensions()->rebuildAllElementReferencesForTarget(this);
    187184        document()->accessSVGExtensions()->removeAllElementReferencesForTarget(this);
    188         document()->accessSVGExtensions()->removeElementFromPendingResources(this);
    189185    }
    190186}
     
    545541    if (name != HTMLNames::styleAttr)
    546542        svgAttributeChanged(name);
    547 }
    548 
    549 bool SVGElement::hasPendingResources() const
    550 {
    551     return hasSVGRareData() && svgRareData()->hasPendingResources();
    552 }
    553 
    554 void SVGElement::setHasPendingResources()
    555 {
    556     ensureSVGRareData()->setHasPendingResources(true);
    557 }
    558 
    559 void SVGElement::clearHasPendingResourcesIfPossible()
    560 {
    561     if (!document()->accessSVGExtensions()->isElementPendingResources(this))
    562         ensureSVGRareData()->setHasPendingResources(false);
    563543}
    564544
  • trunk/Source/WebCore/svg/SVGElement.h

    r138296 r138823  
    7070
    7171    virtual void svgAttributeChanged(const QualifiedName&) { }
    72 
    73     bool hasPendingResources() const;
    74     void setHasPendingResources();
    75     void clearHasPendingResourcesIfPossible();
    76     virtual void buildPendingResource() { }
    7772
    7873    virtual void animatedPropertyTypeForAttribute(const QualifiedName&, Vector<AnimatedPropertyType>&);
  • trunk/Source/WebCore/svg/SVGElementRareData.h

    r137463 r138823  
    4242        , m_correspondingElement(0)
    4343        , m_instancesUpdatesBlocked(false)
    44         , m_hasPendingResources(false)
    4544        , m_useOverrideComputedStyle(false)
    4645        , m_needsOverrideComputedStyleUpdate(false)
     
    6665    bool instanceUpdatesBlocked() const { return m_instancesUpdatesBlocked; }
    6766    void setInstanceUpdatesBlocked(bool value) { m_instancesUpdatesBlocked = value; }
    68 
    69     bool hasPendingResources() const { return m_hasPendingResources; }
    70     void setHasPendingResources(bool value) { m_hasPendingResources = value; }
    7167
    7268    SVGCursorElement* cursorElement() const { return m_cursorElement; }
     
    116112    SVGElement* m_correspondingElement;
    117113    bool m_instancesUpdatesBlocked : 1;
    118     bool m_hasPendingResources : 1;
    119114    bool m_useOverrideComputedStyle : 1;
    120115    bool m_needsOverrideComputedStyleUpdate : 1;
  • trunk/Source/WebCore/svg/SVGStyledElement.cpp

    r137463 r138823  
    369369
    370370    // Rebuild pending resources for each client of a pending resource that is being removed.
    371     while (SVGElement* clientElement = extensions->removeElementFromPendingResourcesForRemoval(resourceId)) {
     371    while (Element* clientElement = extensions->removeElementFromPendingResourcesForRemoval(resourceId)) {
    372372        ASSERT(clientElement->hasPendingResources());
    373373        if (clientElement->hasPendingResources()) {
    374374            clientElement->buildPendingResource();
    375             clientElement->clearHasPendingResourcesIfPossible();
     375            extensions->clearHasPendingResourcesIfPossible(clientElement);
    376376        }
    377377    }
Note: See TracChangeset for help on using the changeset viewer.