Changeset 163295 in webkit


Ignore:
Timestamp:
Feb 3, 2014 1:02:55 AM (10 years ago)
Author:
akling@apple.com
Message:

RenderSVGResource::removeClientFromCache() should take RenderElement&.
<https://webkit.org/b/128097>

Text renderers never have resources associated with them.
This is yet another step towards enforcing that at compile-time
by making all the resource cache interfaces deal in RenderElement.

Also marked the RenderSVGResourceSolidColor class final.

Reviewed by Darin Adler.

  • rendering/svg/RenderSVGResource.cpp:

(WebCore::removeFromCacheAndInvalidateDependencies):
(WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation):

  • rendering/svg/RenderSVGResource.h:
  • rendering/svg/RenderSVGResourceClipper.cpp:

(WebCore::RenderSVGResourceClipper::removeClientFromCache):

  • rendering/svg/RenderSVGResourceClipper.h:
  • rendering/svg/RenderSVGResourceFilter.cpp:

(WebCore::RenderSVGResourceFilter::removeClientFromCache):

  • rendering/svg/RenderSVGResourceFilter.h:
  • rendering/svg/RenderSVGResourceGradient.cpp:

(WebCore::RenderSVGResourceGradient::removeClientFromCache):

  • rendering/svg/RenderSVGResourceGradient.h:
  • rendering/svg/RenderSVGResourceMarker.cpp:

(WebCore::RenderSVGResourceMarker::removeClientFromCache):

  • rendering/svg/RenderSVGResourceMarker.h:
  • rendering/svg/RenderSVGResourceMasker.cpp:

(WebCore::RenderSVGResourceMasker::removeClientFromCache):

  • rendering/svg/RenderSVGResourceMasker.h:
  • rendering/svg/RenderSVGResourcePattern.cpp:

(WebCore::RenderSVGResourcePattern::removeClientFromCache):

  • rendering/svg/RenderSVGResourcePattern.h:
  • rendering/svg/RenderSVGResourceSolidColor.h:
  • rendering/svg/SVGRenderSupport.cpp:

(WebCore::invalidateResourcesOfChildren):
(WebCore::SVGRenderSupport::layoutChildren):

  • rendering/svg/SVGResources.cpp:

(WebCore::SVGResources::removeClientFromCache):

  • rendering/svg/SVGResources.h:
Location:
trunk/Source/WebCore
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r163294 r163295  
     12014-02-03  Andreas Kling  <akling@apple.com>
     2
     3        RenderSVGResource::removeClientFromCache() should take RenderElement&.
     4        <https://webkit.org/b/128097>
     5
     6        Text renderers never have resources associated with them.
     7        This is yet another step towards enforcing that at compile-time
     8        by making all the resource cache interfaces deal in RenderElement.
     9
     10        Also marked the RenderSVGResourceSolidColor class final.
     11
     12        Reviewed by Darin Adler.
     13
     14        * rendering/svg/RenderSVGResource.cpp:
     15        (WebCore::removeFromCacheAndInvalidateDependencies):
     16        (WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation):
     17        * rendering/svg/RenderSVGResource.h:
     18        * rendering/svg/RenderSVGResourceClipper.cpp:
     19        (WebCore::RenderSVGResourceClipper::removeClientFromCache):
     20        * rendering/svg/RenderSVGResourceClipper.h:
     21        * rendering/svg/RenderSVGResourceFilter.cpp:
     22        (WebCore::RenderSVGResourceFilter::removeClientFromCache):
     23        * rendering/svg/RenderSVGResourceFilter.h:
     24        * rendering/svg/RenderSVGResourceGradient.cpp:
     25        (WebCore::RenderSVGResourceGradient::removeClientFromCache):
     26        * rendering/svg/RenderSVGResourceGradient.h:
     27        * rendering/svg/RenderSVGResourceMarker.cpp:
     28        (WebCore::RenderSVGResourceMarker::removeClientFromCache):
     29        * rendering/svg/RenderSVGResourceMarker.h:
     30        * rendering/svg/RenderSVGResourceMasker.cpp:
     31        (WebCore::RenderSVGResourceMasker::removeClientFromCache):
     32        * rendering/svg/RenderSVGResourceMasker.h:
     33        * rendering/svg/RenderSVGResourcePattern.cpp:
     34        (WebCore::RenderSVGResourcePattern::removeClientFromCache):
     35        * rendering/svg/RenderSVGResourcePattern.h:
     36        * rendering/svg/RenderSVGResourceSolidColor.h:
     37        * rendering/svg/SVGRenderSupport.cpp:
     38        (WebCore::invalidateResourcesOfChildren):
     39        (WebCore::SVGRenderSupport::layoutChildren):
     40        * rendering/svg/SVGResources.cpp:
     41        (WebCore::SVGResources::removeClientFromCache):
     42        * rendering/svg/SVGResources.h:
     43
    1442014-02-03  Dan Bernstein  <mitz@apple.com>
    245
  • trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp

    r163283 r163295  
    157157}
    158158
    159 static inline void removeFromCacheAndInvalidateDependencies(RenderObject& object, bool needsLayout)
    160 {
    161     if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object)) {
     159static inline void removeFromCacheAndInvalidateDependencies(RenderElement& renderer, bool needsLayout)
     160{
     161    if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(renderer)) {
    162162#if ENABLE(FILTERS)
    163163        if (RenderSVGResourceFilter* filter = resources->filter())
    164             filter->removeClientFromCache(object);
     164            filter->removeClientFromCache(renderer);
    165165#endif
    166166        if (RenderSVGResourceMasker* masker = resources->masker())
    167             masker->removeClientFromCache(object);
     167            masker->removeClientFromCache(renderer);
    168168
    169169        if (RenderSVGResourceClipper* clipper = resources->clipper())
    170             clipper->removeClientFromCache(object);
    171     }
    172 
    173     if (!object.node() || !object.node()->isSVGElement())
     170            clipper->removeClientFromCache(renderer);
     171    }
     172
     173    if (!renderer.element() || !renderer.element()->isSVGElement())
    174174        return;
    175     HashSet<SVGElement*>* dependencies = object.document().accessSVGExtensions()->setOfElementsReferencingTarget(toSVGElement(object.node()));
     175    HashSet<SVGElement*>* dependencies = renderer.document().accessSVGExtensions()->setOfElementsReferencingTarget(toSVGElement(renderer.element()));
    176176    if (!dependencies)
    177177        return;
     
    189189        object.setNeedsLayout();
    190190
    191     removeFromCacheAndInvalidateDependencies(object, needsLayout);
     191    if (object.isRenderElement())
     192        removeFromCacheAndInvalidateDependencies(toRenderElement(object), needsLayout);
    192193
    193194    // Invalidate resources in ancestor chain, if needed.
    194     RenderObject* current = object.parent();
     195    auto current = object.parent();
    195196    while (current) {
    196197        removeFromCacheAndInvalidateDependencies(*current, needsLayout);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResource.h

    r160651 r163295  
    6161
    6262    virtual void removeAllClientsFromCache(bool markForInvalidation = true) = 0;
    63     virtual void removeClientFromCache(RenderObject&, bool markForInvalidation = true) = 0;
     63    virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) = 0;
    6464
    6565    virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) = 0;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp

    r163276 r163295  
    6262}
    6363
    64 void RenderSVGResourceClipper::removeClientFromCache(RenderObject& client, bool markForInvalidation)
     64void RenderSVGResourceClipper::removeClientFromCache(RenderElement& client, bool markForInvalidation)
    6565{
    6666    m_clipper.remove(&client);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.h

    r162198 r163295  
    4646    SVGClipPathElement& clipPathElement() const { return toSVGClipPathElement(nodeForNonAnonymous()); }
    4747
    48     virtual void removeAllClientsFromCache(bool markForInvalidation = true);
    49     virtual void removeClientFromCache(RenderObject&, bool markForInvalidation = true);
     48    virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
     49    virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
    5050
    5151    virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) override;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.cpp

    r163283 r163295  
    6565}
    6666
    67 void RenderSVGResourceFilter::removeClientFromCache(RenderObject& client, bool markForInvalidation)
     67void RenderSVGResourceFilter::removeClientFromCache(RenderElement& client, bool markForInvalidation)
    6868{
    6969    if (FilterData* filterData = m_filter.get(&client)) {
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceFilter.h

    r163283 r163295  
    6969    SVGFilterElement& filterElement() const { return toSVGFilterElement(RenderSVGResourceContainer::element()); }
    7070
    71     virtual void removeAllClientsFromCache(bool markForInvalidation = true);
    72     virtual void removeClientFromCache(RenderObject&, bool markForInvalidation = true);
     71    virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
     72    virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
    7373
    7474    virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) override;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp

    r163285 r163295  
    4949}
    5050
    51 void RenderSVGResourceGradient::removeClientFromCache(RenderObject& client, bool markForInvalidation)
     51void RenderSVGResourceGradient::removeClientFromCache(RenderElement& client, bool markForInvalidation)
    5252{
    5353    m_gradientMap.remove(&client);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.h

    r162198 r163295  
    4747
    4848    virtual void removeAllClientsFromCache(bool markForInvalidation = true) override final;
    49     virtual void removeClientFromCache(RenderObject&, bool markForInvalidation = true) override final;
     49    virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override final;
    5050
    5151    virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) override final;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMarker.cpp

    r161418 r163295  
    6060}
    6161
    62 void RenderSVGResourceMarker::removeClientFromCache(RenderObject& client, bool markForInvalidation)
     62void RenderSVGResourceMarker::removeClientFromCache(RenderElement& client, bool markForInvalidation)
    6363{
    6464    markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMarker.h

    r162198 r163295  
    3939    SVGMarkerElement& markerElement() const { return toSVGMarkerElement(RenderSVGResourceContainer::element()); }
    4040
    41     virtual void removeAllClientsFromCache(bool markForInvalidation = true);
    42     virtual void removeClientFromCache(RenderObject&, bool markForInvalidation = true);
     41    virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
     42    virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
    4343
    4444    void draw(PaintInfo&, const AffineTransform&);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp

    r163276 r163295  
    5151}
    5252
    53 void RenderSVGResourceMasker::removeClientFromCache(RenderObject& client, bool markForInvalidation)
     53void RenderSVGResourceMasker::removeClientFromCache(RenderElement& client, bool markForInvalidation)
    5454{
    5555    m_masker.remove(&client);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceMasker.h

    r162198 r163295  
    4444    SVGMaskElement& maskElement() const { return toSVGMaskElement(RenderSVGResourceContainer::element()); }
    4545
    46     virtual void removeAllClientsFromCache(bool markForInvalidation = true);
    47     virtual void removeClientFromCache(RenderObject&, bool markForInvalidation = true);
     46    virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
     47    virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
    4848    virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) override;
    4949    virtual FloatRect resourceBoundingBox(const RenderObject&) override;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp

    r163276 r163295  
    5353}
    5454
    55 void RenderSVGResourcePattern::removeClientFromCache(RenderObject& client, bool markForInvalidation)
     55void RenderSVGResourcePattern::removeClientFromCache(RenderElement& client, bool markForInvalidation)
    5656{
    5757    m_patternMap.remove(&client);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourcePattern.h

    r162198 r163295  
    4646    SVGPatternElement& patternElement() const;
    4747
    48     virtual void removeAllClientsFromCache(bool markForInvalidation = true);
    49     virtual void removeClientFromCache(RenderObject&, bool markForInvalidation = true);
     48    virtual void removeAllClientsFromCache(bool markForInvalidation = true) override;
     49    virtual void removeClientFromCache(RenderElement&, bool markForInvalidation = true) override;
    5050
    5151    virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) override;
  • trunk/Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.h

    r162139 r163295  
    2727namespace WebCore {
    2828
    29 class RenderSVGResourceSolidColor : public RenderSVGResource {
     29class RenderSVGResourceSolidColor final : public RenderSVGResource {
    3030public:
    3131    RenderSVGResourceSolidColor();
    3232    virtual ~RenderSVGResourceSolidColor();
    3333
    34     virtual void removeAllClientsFromCache(bool = true) { }
    35     virtual void removeClientFromCache(RenderObject&, bool = true) { }
     34    virtual void removeAllClientsFromCache(bool = true) override { }
     35    virtual void removeClientFromCache(RenderElement&, bool = true) override { }
    3636
    3737    virtual bool applyResource(RenderElement&, const RenderStyle&, GraphicsContext*&, unsigned short resourceMode) override;
     
    3939    virtual FloatRect resourceBoundingBox(const RenderObject&) override { return FloatRect(); }
    4040
    41     virtual RenderSVGResourceType resourceType() const { return s_resourceType; }
     41    virtual RenderSVGResourceType resourceType() const override { return s_resourceType; }
    4242    static RenderSVGResourceType s_resourceType;
    4343
  • trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp

    r161418 r163295  
    186186}
    187187
    188 static inline void invalidateResourcesOfChildren(RenderObject& start)
    189 {
    190     ASSERT(!start.needsLayout());
    191     if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(start))
    192         resources->removeClientFromCache(start, false);
    193 
    194     for (RenderObject* child = start.firstChildSlow(); child; child = child->nextSibling())
    195         invalidateResourcesOfChildren(*child);
     188static inline void invalidateResourcesOfChildren(RenderElement& renderer)
     189{
     190    ASSERT(!renderer.needsLayout());
     191    if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(renderer))
     192        resources->removeClientFromCache(renderer, false);
     193
     194    for (auto& child : childrenOfType<RenderElement>(renderer))
     195        invalidateResourcesOfChildren(child);
    196196}
    197197
     
    289289
    290290    // If the layout size changed, invalidate all resources of all children that didn't go through the layout() code path.
    291     for (auto child : notlayoutedObjects)
    292         invalidateResourcesOfChildren(*child);
     291    for (auto child : notlayoutedObjects) {
     292        if (child->isRenderElement())
     293            invalidateResourcesOfChildren(toRenderElement(*child));
     294    }
    293295}
    294296
  • trunk/Source/WebCore/rendering/svg/SVGResources.cpp

    r161418 r163295  
    280280}
    281281
    282 void SVGResources::removeClientFromCache(RenderObject& object, bool markForInvalidation) const
     282void SVGResources::removeClientFromCache(RenderElement& renderer, bool markForInvalidation) const
    283283{
    284284    if (!m_clipperFilterMaskerData && !m_markerData && !m_fillStrokeData && !m_linkedResource)
     
    289289        ASSERT(!m_markerData);
    290290        ASSERT(!m_fillStrokeData);
    291         m_linkedResource->removeClientFromCache(object, markForInvalidation);
     291        m_linkedResource->removeClientFromCache(renderer, markForInvalidation);
    292292        return;
    293293    }
     
    295295    if (m_clipperFilterMaskerData) {
    296296        if (m_clipperFilterMaskerData->clipper)
    297             m_clipperFilterMaskerData->clipper->removeClientFromCache(object, markForInvalidation);
     297            m_clipperFilterMaskerData->clipper->removeClientFromCache(renderer, markForInvalidation);
    298298#if ENABLE(FILTERS)
    299299        if (m_clipperFilterMaskerData->filter)
    300             m_clipperFilterMaskerData->filter->removeClientFromCache(object, markForInvalidation);
     300            m_clipperFilterMaskerData->filter->removeClientFromCache(renderer, markForInvalidation);
    301301#endif
    302302        if (m_clipperFilterMaskerData->masker)
    303             m_clipperFilterMaskerData->masker->removeClientFromCache(object, markForInvalidation);
     303            m_clipperFilterMaskerData->masker->removeClientFromCache(renderer, markForInvalidation);
    304304    }
    305305
    306306    if (m_markerData) {
    307307        if (m_markerData->markerStart)
    308             m_markerData->markerStart->removeClientFromCache(object, markForInvalidation);
     308            m_markerData->markerStart->removeClientFromCache(renderer, markForInvalidation);
    309309        if (m_markerData->markerMid)
    310             m_markerData->markerMid->removeClientFromCache(object, markForInvalidation);
     310            m_markerData->markerMid->removeClientFromCache(renderer, markForInvalidation);
    311311        if (m_markerData->markerEnd)
    312             m_markerData->markerEnd->removeClientFromCache(object, markForInvalidation);
     312            m_markerData->markerEnd->removeClientFromCache(renderer, markForInvalidation);
    313313    }
    314314
    315315    if (m_fillStrokeData) {
    316316        if (m_fillStrokeData->fill)
    317             m_fillStrokeData->fill->removeClientFromCache(object, markForInvalidation);
     317            m_fillStrokeData->fill->removeClientFromCache(renderer, markForInvalidation);
    318318        if (m_fillStrokeData->stroke)
    319             m_fillStrokeData->stroke->removeClientFromCache(object, markForInvalidation);
     319            m_fillStrokeData->stroke->removeClientFromCache(renderer, markForInvalidation);
    320320    }
    321321}
  • trunk/Source/WebCore/rendering/svg/SVGResources.h

    r160651 r163295  
    7373
    7474    // Methods operating on all cached resources
    75     void removeClientFromCache(RenderObject&, bool markForInvalidation = true) const;
     75    void removeClientFromCache(RenderElement&, bool markForInvalidation = true) const;
    7676    void resourceDestroyed(RenderSVGResourceContainer&);
    7777
Note: See TracChangeset for help on using the changeset viewer.