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

Changeset 286843 in webkit


Ignore:
Timestamp:
Dec 10, 2021, 4:19:40 AM (5 years ago)
Author:
Nikolas Zimmermann
Message:

[LBSE] Handle RenderSVGRoot in all places that handle LegacyRenderSVGRoot
https://bugs.webkit.org/show_bug.cgi?id=233872

Reviewed by Rob Buis.

Various places that handle LegacyRenderSVGRoot, also need to handle the
LBSE RenderSVGRoot renderer -- this patch plumbs in support for
RenderSVGRoot where necessary.

Covered by existing tests, no change in behaviour.

  • accessibility/AccessibilityRenderObject.cpp:

(WebCore::AccessibilityRenderObject::elementPath const):

  • page/FrameView.cpp:

(WebCore::FrameView::applyOverflowToViewport):

  • rendering/RenderTreeAsText.cpp:

(WebCore::write):

  • rendering/svg/RenderSVGResource.cpp:

(WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation):

  • rendering/svg/SVGRenderSupport.cpp:

(WebCore::layoutSizeOfNearestViewportChanged):

  • rendering/svg/SVGRenderTreeAsText.cpp:

(WebCore::write):

  • rendering/svg/SVGRenderTreeAsText.h:
  • rendering/updating/RenderTreeBuilder.cpp:

(WebCore::RenderTreeBuilder::attachInternal):
(WebCore::RenderTreeBuilder::detach):

  • rendering/updating/RenderTreeBuilderSVG.cpp:

(WebCore::RenderTreeBuilder::SVG::attach):
(WebCore::RenderTreeBuilder::SVG::detach):

  • rendering/updating/RenderTreeBuilderSVG.h:
  • svg/SVGElement.cpp:

(WebCore::SVGElement::childShouldCreateRenderer const):

  • svg/SVGSVGElement.cpp:

(WebCore::SVGSVGElement::svgAttributeChanged):
(WebCore::SVGSVGElement::currentViewBoxRect const):
(WebCore::SVGSVGElement::currentViewportSize const):

Location:
trunk/Source/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286842 r286843  
     12021-12-10  Nikolas Zimmermann  <nzimmermann@igalia.com>
     2
     3        [LBSE] Handle RenderSVGRoot in all places that handle LegacyRenderSVGRoot
     4        https://bugs.webkit.org/show_bug.cgi?id=233872
     5
     6        Reviewed by Rob Buis.
     7
     8        Various places that handle LegacyRenderSVGRoot, also need to handle the
     9        LBSE RenderSVGRoot renderer -- this patch plumbs in support for
     10        RenderSVGRoot where necessary.
     11
     12        Covered by existing tests, no change in behaviour.
     13
     14        * accessibility/AccessibilityRenderObject.cpp:
     15        (WebCore::AccessibilityRenderObject::elementPath const):
     16        * page/FrameView.cpp:
     17        (WebCore::FrameView::applyOverflowToViewport):
     18        * rendering/RenderTreeAsText.cpp:
     19        (WebCore::write):
     20        * rendering/svg/RenderSVGResource.cpp:
     21        (WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation):
     22        * rendering/svg/SVGRenderSupport.cpp:
     23        (WebCore::layoutSizeOfNearestViewportChanged):
     24        * rendering/svg/SVGRenderTreeAsText.cpp:
     25        (WebCore::write):
     26        * rendering/svg/SVGRenderTreeAsText.h:
     27        * rendering/updating/RenderTreeBuilder.cpp:
     28        (WebCore::RenderTreeBuilder::attachInternal):
     29        (WebCore::RenderTreeBuilder::detach):
     30        * rendering/updating/RenderTreeBuilderSVG.cpp:
     31        (WebCore::RenderTreeBuilder::SVG::attach):
     32        (WebCore::RenderTreeBuilder::SVG::detach):
     33        * rendering/updating/RenderTreeBuilderSVG.h:
     34        * svg/SVGElement.cpp:
     35        (WebCore::SVGElement::childShouldCreateRenderer const):
     36        * svg/SVGSVGElement.cpp:
     37        (WebCore::SVGSVGElement::svgAttributeChanged):
     38        (WebCore::SVGSVGElement::currentViewBoxRect const):
     39        (WebCore::SVGSVGElement::currentViewportSize const):
     40
    1412021-12-10  Nikolas Zimmermann  <nzimmermann@igalia.com>
    242
  • trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp

    r286542 r286843  
    9595#include "RenderMathMLBlock.h"
    9696#include "RenderMenuList.h"
     97#include "RenderSVGRoot.h"
    9798#include "RenderSVGShape.h"
    9899#include "RenderTableCell.h"
     
    955956            LayoutPoint parentOffset = axObjectCache()->getOrCreate(&*svgRoot)->elementRect().location();
    956957            path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y()));
     958#if ENABLE(LAYER_BASED_SVG_ENGINE)
     959        } else if (auto svgRoot = ancestorsOfType<RenderSVGRoot>(*m_renderer).first()) {
     960            LayoutPoint parentOffset = axObjectCache()->getOrCreate(&*svgRoot)->elementRect().location();
     961            path.transform(AffineTransform().translate(parentOffset.x(), parentOffset.y()));
     962#endif
    957963        }
    958964
  • trunk/Source/WebCore/page/FrameView.cpp

    r286772 r286843  
    8888#include "RenderLayerCompositor.h"
    8989#include "RenderLayerScrollableArea.h"
     90#include "RenderSVGRoot.h"
    9091#include "RenderScrollbar.h"
    9192#include "RenderScrollbarPart.h"
     
    648649    Overflow overflowY = renderer.effectiveOverflowY();
    649650
     651#if ENABLE(LAYER_BASED_SVG_ENGINE)
     652    if (is<RenderSVGRoot>(renderer)) {
     653        // FIXME: evaluate if we can allow overflow for these cases too.
     654        // Overflow is always hidden when stand-alone SVG documents are embedded.
     655        if (downcast<RenderSVGRoot>(renderer).isEmbeddedThroughFrameContainingSVGDocument()) {
     656            overflowX = Overflow::Hidden;
     657            overflowY = Overflow::Hidden;
     658        }
     659    }
     660#endif
     661
    650662    if (is<LegacyRenderSVGRoot>(renderer)) {
    651663        // FIXME: evaluate if we can allow overflow for these cases too.
  • trunk/Source/WebCore/rendering/RenderTreeAsText.cpp

    r286392 r286843  
    6464#include "RenderSVGPath.h"
    6565#include "RenderSVGResourceContainer.h"
     66#include "RenderSVGRoot.h"
    6667#include "RenderSVGText.h"
    6768#include "RenderTableCell.h"
     
    574575        return;
    575576    }
     577#if ENABLE(LAYER_BASED_SVG_ENGINE)
     578    if (is<RenderSVGRoot>(o)) {
     579        write(ts, downcast<RenderSVGRoot>(o), behavior);
     580        return;
     581    }
     582#endif
    576583    if (is<LegacyRenderSVGRoot>(o)) {
    577584        write(ts, downcast<LegacyRenderSVGRoot>(o), behavior);
  • trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp

    r286392 r286843  
    3131#include "RenderSVGResourceMasker.h"
    3232#include "RenderSVGResourceSolidColor.h"
     33#include "RenderSVGRoot.h"
    3334#include "RenderView.h"
    3435#include "SVGResourceElementClient.h"
     
    203204        if (is<LegacyRenderSVGRoot>(object) && downcast<LegacyRenderSVGRoot>(object).isInLayout())
    204205            object.setNeedsLayout(MarkOnlyThis);
     206#if ENABLE(LAYER_BASED_SVG_ENGINE)
     207        else if (is<RenderSVGRoot>(object) && downcast<RenderSVGRoot>(object).isInLayout())
     208            object.setNeedsLayout(MarkOnlyThis);
     209#endif
    205210        else
    206211            object.setNeedsLayout(MarkContainingBlockChain);
  • trunk/Source/WebCore/rendering/svg/SVGRenderSupport.cpp

    r286795 r286843  
    4141#include "RenderSVGResourceMarker.h"
    4242#include "RenderSVGResourceMasker.h"
     43#include "RenderSVGRoot.h"
    4344#include "RenderSVGText.h"
    4445#include "RenderSVGTransformableContainer.h"
     
    212213        return downcast<RenderSVGViewportContainer>(*start).isLayoutSizeChanged();
    213214
     215#if ENABLE(LAYER_BASED_SVG_ENGINE)
     216    if (is<RenderSVGRoot>(*start))
     217        return downcast<RenderSVGRoot>(*start).isLayoutSizeChanged();
     218#endif
    214219    return downcast<LegacyRenderSVGRoot>(*start).isLayoutSizeChanged();
    215220}
  • trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp

    r286795 r286843  
    4848#include "RenderSVGResourceRadialGradientInlines.h"
    4949#include "RenderSVGResourceSolidColor.h"
     50#include "RenderSVGRoot.h"
    5051#include "RenderSVGShapeInlines.h"
    5152#include "RenderSVGText.h"
     
    508509}
    509510
     511#if ENABLE(LAYER_BASED_SVG_ENGINE)
     512void write(TextStream& ts, const RenderSVGRoot& root, OptionSet<RenderAsTextFlag> behavior)
     513{
     514    writeStandardPrefix(ts, root, behavior);
     515    writePositionAndStyle(ts, root, behavior);
     516    ts << "\n";
     517    writeChildren(ts, root, behavior);
     518}
     519#endif
     520
    510521void write(TextStream& ts, const LegacyRenderSVGRoot& root, OptionSet<RenderAsTextFlag> behavior)
    511522{
  • trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h

    r286392 r286843  
    3131namespace WebCore {
    3232
     33class AffineTransform;
    3334class Color;
    3435class FloatRect;
    3536class FloatSize;
     37class LegacyRenderSVGRoot;
    3638class Node;
    3739class RenderImage;
     
    4244class RenderSVGInlineText;
    4345class RenderSVGResourceContainer;
     46class RenderSVGRoot;
    4447class RenderSVGShape;
    45 class LegacyRenderSVGRoot;
    4648class RenderSVGText;
    47 class AffineTransform;
    4849class SVGUnitTypes;
    4950
    5051// functions used by the main RenderTreeAsText code
     52void write(WTF::TextStream&, const LegacyRenderSVGRoot&, OptionSet<RenderAsTextFlag>);
     53#if ENABLE(LAYER_BASED_SVG_ENGINE)
     54void write(WTF::TextStream&, const RenderSVGRoot&, OptionSet<RenderAsTextFlag>);
     55#endif
    5156void write(WTF::TextStream&, const RenderSVGShape&, OptionSet<RenderAsTextFlag>);
    52 void write(WTF::TextStream&, const LegacyRenderSVGRoot&, OptionSet<RenderAsTextFlag>);
    5357void writeSVGGradientStop(WTF::TextStream&, const RenderSVGGradientStop&, OptionSet<RenderAsTextFlag>);
    5458void writeSVGResourceContainer(WTF::TextStream&, const RenderSVGResourceContainer&, OptionSet<RenderAsTextFlag>);
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilder.cpp

    r286542 r286843  
    5151#include "RenderSVGContainer.h"
    5252#include "RenderSVGInline.h"
     53#include "RenderSVGRoot.h"
    5354#include "RenderSVGText.h"
    5455#include "RenderTable.h"
     
    291292    }
    292293
     294#if ENABLE(LAYER_BASED_SVG_ENGINE)
     295    if (is<RenderSVGRoot>(parent)) {
     296        svgBuilder().attach(downcast<RenderSVGRoot>(parent), WTFMove(child), beforeChild);
     297        return;
     298    }
     299#endif
     300
    293301    if (is<LegacyRenderSVGRoot>(parent)) {
    294302        svgBuilder().attach(downcast<LegacyRenderSVGRoot>(parent), WTFMove(child), beforeChild);
     
    374382    if (is<RenderSVGContainer>(parent))
    375383        return svgBuilder().detach(downcast<RenderSVGContainer>(parent), child);
     384
     385#if ENABLE(LAYER_BASED_SVG_ENGINE)
     386    if (is<RenderSVGRoot>(parent))
     387        return svgBuilder().detach(downcast<RenderSVGRoot>(parent), child);
     388#endif
    376389
    377390    if (is<LegacyRenderSVGRoot>(parent))
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.cpp

    r286392 r286843  
    3030#include "RenderSVGContainer.h"
    3131#include "RenderSVGInline.h"
     32#include "RenderSVGRoot.h"
    3233#include "RenderSVGText.h"
    3334#include "RenderTreeBuilderBlock.h"
     
    4142    : m_builder(builder)
    4243{
     44}
     45
     46void RenderTreeBuilder::SVG::attach(LegacyRenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
     47{
     48    auto& childToAdd = *child;
     49    m_builder.attachToRenderElement(parent, WTFMove(child), beforeChild);
     50    SVGResourcesCache::clientWasAddedToTree(childToAdd);
    4351}
    4452
     
    6068}
    6169
    62 void RenderTreeBuilder::SVG::attach(LegacyRenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
     70#if ENABLE(LAYER_BASED_SVG_ENGINE)
     71void RenderTreeBuilder::SVG::attach(RenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
    6372{
    6473    auto& childToAdd = *child;
     
    6675    SVGResourcesCache::clientWasAddedToTree(childToAdd);
    6776}
     77#endif
    6878
    6979void RenderTreeBuilder::SVG::attach(RenderSVGText& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild)
     
    7484    SVGResourcesCache::clientWasAddedToTree(childToAdd);
    7585    parent.subtreeChildWasAdded(&childToAdd);
     86}
     87
     88RenderPtr<RenderObject> RenderTreeBuilder::SVG::detach(LegacyRenderSVGRoot& parent, RenderObject& child)
     89{
     90    SVGResourcesCache::clientWillBeRemovedFromTree(child);
     91    return m_builder.detachFromRenderElement(parent, child);
    7692}
    7793
     
    108124}
    109125
    110 RenderPtr<RenderObject> RenderTreeBuilder::SVG::detach(LegacyRenderSVGRoot& parent, RenderObject& child)
     126#if ENABLE(LAYER_BASED_SVG_ENGINE)
     127RenderPtr<RenderObject> RenderTreeBuilder::SVG::detach(RenderSVGRoot& parent, RenderObject& child)
    111128{
    112129    SVGResourcesCache::clientWillBeRemovedFromTree(child);
    113130    return m_builder.detachFromRenderElement(parent, child);
    114131}
     132#endif
    115133
    116134}
  • trunk/Source/WebCore/rendering/updating/RenderTreeBuilderSVG.h

    r286392 r286843  
    3030namespace WebCore {
    3131
     32class LegacyRenderSVGRoot;
    3233class RenderSVGContainer;
    3334class RenderSVGInline;
    34 class LegacyRenderSVGRoot;
     35class RenderSVGRoot;
    3536class RenderSVGText;
    3637
     
    4041    SVG(RenderTreeBuilder&);
    4142
     43    void attach(LegacyRenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
    4244    void attach(RenderSVGContainer& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
    4345    void attach(RenderSVGInline& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
    44     void attach(LegacyRenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
     46#if ENABLE(LAYER_BASED_SVG_ENGINE)
     47    void attach(RenderSVGRoot& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
     48#endif
    4549    void attach(RenderSVGText& parent, RenderPtr<RenderObject> child, RenderObject* beforeChild);
    4650
     51    RenderPtr<RenderObject> detach(LegacyRenderSVGRoot& parent, RenderObject& child) WARN_UNUSED_RETURN;
     52    RenderPtr<RenderObject> detach(RenderSVGContainer& parent, RenderObject& child) WARN_UNUSED_RETURN;
     53    RenderPtr<RenderObject> detach(RenderSVGInline& parent, RenderObject& child) WARN_UNUSED_RETURN;
     54#if ENABLE(LAYER_BASED_SVG_ENGINE)
     55    RenderPtr<RenderObject> detach(RenderSVGRoot& parent, RenderObject& child) WARN_UNUSED_RETURN;
     56#endif
    4757    RenderPtr<RenderObject> detach(RenderSVGText& parent, RenderObject& child) WARN_UNUSED_RETURN;
    48     RenderPtr<RenderObject> detach(RenderSVGInline& parent, RenderObject& child) WARN_UNUSED_RETURN;
    49     RenderPtr<RenderObject> detach(RenderSVGContainer& parent, RenderObject& child) WARN_UNUSED_RETURN;
    50     RenderPtr<RenderObject> detach(LegacyRenderSVGRoot& parent, RenderObject& child) WARN_UNUSED_RETURN;
    5158
    5259private:
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r285630 r286843  
    530530        return false;
    531531    auto& svgChild = downcast<SVGElement>(child);
     532
     533#if ENABLE(LAYER_BASED_SVG_ENGINE)
     534    // If the layer based SVG engine is enabled, all renderers that do not support the
     535    // RenderLayer aware layout / painting / hit-testing mode ('LBSE-mode') have to be skipped.
     536    // Currently all renderers are skipped.
     537    if (document().settings().layerBasedSVGEngineEnabled())
     538        return false;
     539#endif
    532540
    533541    static const QualifiedName* const invalidTextContent[] {
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r286392 r286843  
    3333#include "LegacyRenderSVGRoot.h"
    3434#include "RenderSVGResource.h"
     35#include "RenderSVGRoot.h"
    3536#include "RenderSVGViewportContainer.h"
    3637#include "RenderView.h"
     
    212213
    213214        if (auto renderer = this->renderer()) {
     215#if ENABLE(LAYER_BASED_SVG_ENGINE)
     216            if (is<RenderSVGRoot>(renderer) && downcast<RenderSVGRoot>(*renderer).isEmbeddedThroughFrameContainingSVGDocument())
     217                RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
     218#endif
    214219            if (is<LegacyRenderSVGRoot>(renderer) && downcast<LegacyRenderSVGRoot>(*renderer).isEmbeddedThroughFrameContainingSVGDocument())
    215220                RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
     
    476481        return viewBox;
    477482
    478     if (!is<LegacyRenderSVGRoot>(renderer()))
    479         return { };
    480     if (!downcast<LegacyRenderSVGRoot>(*renderer()).isEmbeddedThroughSVGImage())
     483    bool isEmbeddedThroughSVGImage = false;
     484    if (is<LegacyRenderSVGRoot>(renderer()) && downcast<LegacyRenderSVGRoot>(*renderer()).isEmbeddedThroughSVGImage())
     485        isEmbeddedThroughSVGImage = true;
     486#if ENABLE(LAYER_BASED_SVG_ENGINE)
     487    else if (is<RenderSVGRoot>(renderer()) && downcast<RenderSVGRoot>(*renderer()).isEmbeddedThroughSVGImage())
     488        isEmbeddedThroughSVGImage = true;
     489#endif
     490
     491    if (!isEmbeddedThroughSVGImage)
    481492        return { };
    482493
     
    487498
    488499    // If no viewBox is specified but non-relative width/height values, then we
    489     // should always synthesize a viewBox if we're embedded through a SVGImage.   
     500    // should always synthesize a viewBox if we're embedded through a SVGImage.
    490501    return { 0, 0, floatValueForLength(intrinsicWidth, 0), floatValueForLength(intrinsicHeight, 0) };
    491502}
     
    499510            auto& root = downcast<LegacyRenderSVGRoot>(*renderer());
    500511            viewportSize = root.contentBoxRect().size() / root.style().effectiveZoom();
     512#if ENABLE(LAYER_BASED_SVG_ENGINE)
     513        } else if (is<RenderSVGRoot>(*renderer())) {
     514            auto& root = downcast<RenderSVGRoot>(*renderer());
     515            viewportSize = root.contentBoxRect().size() / root.style().effectiveZoom();
     516#endif
    501517        } else
    502518            viewportSize = downcast<RenderSVGViewportContainer>(*renderer()).viewport().size();
Note: See TracChangeset for help on using the changeset viewer.