⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 271232 in webkit


Ignore:
Timestamp:
Jan 7, 2021, 2:05:19 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Only update the resources when rendering SVG selected text
https://bugs.webkit.org/show_bug.cgi?id=218486

Patch by Carlos Garcia Campos <cgarcia@igalia.com> on 2021-01-07
Reviewed by Ryosuke Niwa.

Instead of calling SVGResourcesCache::clientStyleChanged() that marks the renderer for layout and parent
resource invalidation, add a helper class SVGResourcesCache::SetStyleForScope() that just updates the resources
for the new style on construction and restores the previous one on destruction.

  • rendering/svg/SVGInlineTextBox.cpp:

(WebCore::SVGInlineTextBox::paintText): Use SVGResourcesCache::SetStyleForScope().

  • rendering/svg/SVGResourcesCache.cpp:

(WebCore::SVGResourcesCache::SetStyleForScope::SetStyleForScope): Call setStyle() with the new style.
(WebCore::SVGResourcesCache::SetStyleForScope::~SetStyleForScope): Call setStyle() with the previous style.
(WebCore::SVGResourcesCache::SetStyleForScope::setStyle): Set the given style if needed.

  • rendering/svg/SVGResourcesCache.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r271231 r271232  
     12021-01-07  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Only update the resources when rendering SVG selected text
     4        https://bugs.webkit.org/show_bug.cgi?id=218486
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Instead of calling SVGResourcesCache::clientStyleChanged() that marks the renderer for layout and parent
     9        resource invalidation, add a helper class SVGResourcesCache::SetStyleForScope() that just updates the resources
     10        for the new style on construction and restores the previous one on destruction.
     11
     12        * rendering/svg/SVGInlineTextBox.cpp:
     13        (WebCore::SVGInlineTextBox::paintText): Use SVGResourcesCache::SetStyleForScope().
     14        * rendering/svg/SVGResourcesCache.cpp:
     15        (WebCore::SVGResourcesCache::SetStyleForScope::SetStyleForScope): Call setStyle() with the new style.
     16        (WebCore::SVGResourcesCache::SetStyleForScope::~SetStyleForScope): Call setStyle() with the previous style.
     17        (WebCore::SVGResourcesCache::SetStyleForScope::setStyle): Set the given style if needed.
     18        * rendering/svg/SVGResourcesCache.h:
     19
    1202021-01-07  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r265338 r271232  
    603603
    604604    // Draw text using selection style from the start to the end position of the selection
    605     if (style != selectionStyle)
    606         SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifference::Repaint, selectionStyle);
    607 
    608     paintTextWithShadows(context, selectionStyle, textRun, fragment, startPosition, endPosition);
    609 
    610     if (style != selectionStyle)
    611         SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifference::Repaint, style);
     605    {
     606        SVGResourcesCache::SetStyleForScope temporaryStyleChange(parent()->renderer(), style, selectionStyle);
     607        paintTextWithShadows(context, selectionStyle, textRun, fragment, startPosition, endPosition);
     608    }
    612609
    613610    // Eventually draw text using regular style from the end position of the selection to the end of the current chunk part
  • trunk/Source/WebCore/rendering/svg/SVGResourcesCache.cpp

    r248846 r271232  
    170170}
    171171
     172SVGResourcesCache::SetStyleForScope::SetStyleForScope(RenderElement& renderer, const RenderStyle& scopedStyle, const RenderStyle& newStyle)
     173    : m_renderer(renderer)
     174    , m_scopedStyle(scopedStyle)
     175    , m_needsNewStyle(scopedStyle != newStyle && rendererCanHaveResources(renderer))
     176{
     177    setStyle(newStyle);
    172178}
     179
     180SVGResourcesCache::SetStyleForScope::~SetStyleForScope()
     181{
     182    setStyle(m_scopedStyle);
     183}
     184
     185void SVGResourcesCache::SetStyleForScope::setStyle(const RenderStyle& style)
     186{
     187    if (!m_needsNewStyle)
     188        return;
     189
     190    auto& cache = resourcesCacheFromRenderer(m_renderer);
     191    cache.removeResourcesFromRenderer(m_renderer);
     192    cache.addResourcesFromRenderer(m_renderer, style);
     193}
     194
     195}
  • trunk/Source/WebCore/rendering/svg/SVGResourcesCache.h

    r208668 r271232  
    5959    static void resourceDestroyed(RenderSVGResourceContainer&);
    6060
     61    class SetStyleForScope {
     62        WTF_MAKE_NONCOPYABLE(SetStyleForScope);
     63    public:
     64        SetStyleForScope(RenderElement&, const RenderStyle& scopedStyle, const RenderStyle& newStyle);
     65        ~SetStyleForScope();
     66    private:
     67        void setStyle(const RenderStyle&);
     68
     69        RenderElement& m_renderer;
     70        const RenderStyle& m_scopedStyle;
     71        bool m_needsNewStyle { false };
     72    };
     73
    6174private:
    6275    void addResourcesFromRenderer(RenderElement&, const RenderStyle&);
Note: See TracChangeset for help on using the changeset viewer.