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

Changeset 286846 in webkit


Ignore:
Timestamp:
Dec 10, 2021, 5:51:02 AM (5 years ago)
Author:
Nikolas Zimmermann
Message:

[LBSE] Create RenderSVGRoot renderer for outermost <svg> and allow direct <rect> children
https://bugs.webkit.org/show_bug.cgi?id=233873

Reviewed by Rob Buis.

Construct RenderSVGRoot renderers for the outermost <svg> element when LBSE is enabled.
An 'allowlist' approach is used to only create renderers for those SVG elements that
are aware of LBSE: outermost <svg> element + <rect> element. For all other elements
no renderers will be created in LBSE for now.

This patch leaves the legacy engine unchanged (probed by EWS & local test runs),
and also LBSE shows no assertions/crashes/hangs in release/debug builds - tested
with "run-webkit-tests --internal-feature=LayerBasedSVGEngineEnabled".

Note that many layout tests will either timeout or show a different result,
due to the small capabilities of LBSE at present. Therefore it's beneficial to
decrease timeouts / use more workers when running layout tests. Otherwise they
will take a long time to complete. On my macOS Monterey M1 MacBook, following
parameters lead to a reasonable test execution time:

run-webkit-tests --internal-feature=LayerBasedSVGEngineEnabled --timeout=5000 \
--no-sample-on-timeout --no-retry-failures --child-processes=15 \
[--release / --debug] svg

Covered by existing tests.

  • rendering/svg/RenderSVGModelObject.cpp:

(WebCore::RenderSVGModelObject::clippedOverflowRect const):
(WebCore::RenderSVGModelObject::nodeAtPoint):

  • rendering/svg/RenderSVGModelObject.h:

(WebCore::RenderSVGModelObject::visualOverflowRectEquivalent const):

  • svg/SVGElement.cpp:

(WebCore::createSVGLayerAwareElementSet):
(WebCore::isSVGLayerAwareElement):
(WebCore::SVGElement::childShouldCreateRenderer const):

  • svg/SVGSVGElement.cpp:

(WebCore::SVGSVGElement::createElementRenderer):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r286845 r286846  
     12021-12-10  Nikolas Zimmermann  <nzimmermann@igalia.com>
     2
     3        [LBSE] Create RenderSVGRoot renderer for outermost <svg> and allow direct <rect> children
     4        https://bugs.webkit.org/show_bug.cgi?id=233873
     5
     6        Reviewed by Rob Buis.
     7
     8        Construct RenderSVGRoot renderers for the outermost <svg> element when LBSE is enabled.
     9        An 'allowlist' approach is used to only create renderers for those SVG elements that
     10        are aware of LBSE: outermost <svg> element + <rect> element. For all other elements
     11        no renderers will be created in LBSE for now.
     12
     13        This patch leaves the legacy engine unchanged (probed by EWS & local test runs),
     14        and also LBSE shows no assertions/crashes/hangs in release/debug builds - tested
     15        with "run-webkit-tests --internal-feature=LayerBasedSVGEngineEnabled".
     16
     17        Note that many layout tests will either timeout or show a different result,
     18        due to the small capabilities of LBSE at present. Therefore it's beneficial to
     19        decrease timeouts / use more workers when running layout tests. Otherwise they
     20        will take a long time to complete. On my macOS Monterey M1 MacBook, following
     21        parameters lead to a reasonable test execution time:
     22
     23        run-webkit-tests --internal-feature=LayerBasedSVGEngineEnabled --timeout=5000 \
     24        --no-sample-on-timeout --no-retry-failures --child-processes=15 \
     25        [--release / --debug] svg
     26
     27        Covered by existing tests.
     28
     29        * rendering/svg/RenderSVGModelObject.cpp:
     30        (WebCore::RenderSVGModelObject::clippedOverflowRect const):
     31        (WebCore::RenderSVGModelObject::nodeAtPoint):
     32        * rendering/svg/RenderSVGModelObject.h:
     33        (WebCore::RenderSVGModelObject::visualOverflowRectEquivalent const):
     34        * svg/SVGElement.cpp:
     35        (WebCore::createSVGLayerAwareElementSet):
     36        (WebCore::isSVGLayerAwareElement):
     37        (WebCore::SVGElement::childShouldCreateRenderer const):
     38        * svg/SVGSVGElement.cpp:
     39        (WebCore::SVGSVGElement::createElementRenderer):
     40
    1412021-12-10  Antti Koivisto  <antti@apple.com>
    242
  • trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.cpp

    r285195 r286846  
    3232#include "RenderSVGModelObject.h"
    3333
     34#include "NotImplemented.h"
     35#include "RenderLayer.h"
    3436#include "RenderLayerModelObject.h"
    3537#include "RenderSVGResource.h"
     38#include "RenderView.h"
    3639#include "SVGElementInlines.h"
    3740#include "SVGNames.h"
     
    4952}
    5053
    51 LayoutRect RenderSVGModelObject::clippedOverflowRect(const RenderLayerModelObject* repaintContainer, VisibleRectContext) const
    52 {
     54LayoutRect RenderSVGModelObject::clippedOverflowRect(const RenderLayerModelObject* repaintContainer, VisibleRectContext context) const
     55{
     56#if ENABLE(LAYER_BASED_SVG_ENGINE)
     57    if (document().settings().layerBasedSVGEngineEnabled()) {
     58        if (style().visibility() != Visibility::Visible && !enclosingLayer()->hasVisibleContent())
     59            return LayoutRect();
     60
     61        ASSERT(!view().frameView().layoutContext().isPaintOffsetCacheEnabled());
     62        return computeRect(visualOverflowRectEquivalent(), repaintContainer, context);
     63    }
     64#else
     65    UNUSED_PARAM(context);
     66#endif
     67
    5368    return SVGRenderSupport::clippedOverflowRectForRepaint(*this, repaintContainer);
    5469}
     
    112127bool RenderSVGModelObject::nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint&, HitTestAction)
    113128{
     129#if ENABLE(LAYER_BASED_SVG_ENGINE)
     130    if (document().settings().layerBasedSVGEngineEnabled()) {
     131        // FIXME: [LBSE] Upstream RenderSVGModelObject inheritance changes (should inherit from RenderLayerModelObject).
     132        notImplemented();
     133        return false;
     134    }
     135#endif
     136
    114137    ASSERT_NOT_REACHED();
    115138    return false;
  • trunk/Source/WebCore/rendering/svg/RenderSVGModelObject.h

    r281239 r286846  
    6363    SVGElement& element() const { return downcast<SVGElement>(nodeForNonAnonymous()); }
    6464
     65    // FIXME: [LBSE] Upstream SVGBoundingBoxComputation
     66    // LayoutRect visualOverflowRectEquivalent() const { return SVGBoundingBoxComputation::computeVisualOverflowRect(*this); }
     67    LayoutRect visualOverflowRectEquivalent() const { return LayoutRect(); }
     68
    6569protected:
    6670    RenderSVGModelObject(SVGElement&, RenderStyle&&);
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r286843 r286846  
    525525}
    526526
     527#if ENABLE(LAYER_BASED_SVG_ENGINE)
     528static MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> createSVGLayerAwareElementSet()
     529{
     530    // List of all SVG elements whose renderers support the layer aware layout / painting / hit-testing mode ('LBSE-mode').
     531    using namespace SVGNames;
     532    MemoryCompactLookupOnlyRobinHoodHashSet<AtomString> set;
     533    for (auto& tag : { rectTag.get() })
     534        set.add(tag.localName());
     535    return set;
     536}
     537
     538static inline bool isSVGLayerAwareElement(const SVGElement& element)
     539{
     540    static NeverDestroyed<MemoryCompactLookupOnlyRobinHoodHashSet<AtomString>> set = createSVGLayerAwareElementSet();
     541    return set.get().contains(element.localName());
     542}
     543#endif
     544
    527545bool SVGElement::childShouldCreateRenderer(const Node& child) const
    528546{
     
    534552    // If the layer based SVG engine is enabled, all renderers that do not support the
    535553    // RenderLayer aware layout / painting / hit-testing mode ('LBSE-mode') have to be skipped.
    536     // Currently all renderers are skipped.
     554    // FIXME: [LBSE] Upstream support for all elements, and remove 'isSVGLayerAwareElement' check afterwards.
    537555    if (document().settings().layerBasedSVGEngineEnabled())
    538         return false;
     556        return isSVGLayerAwareElement(svgChild);
    539557#endif
    540558
  • trunk/Source/WebCore/svg/SVGSVGElement.cpp

    r286843 r286846  
    399399RenderPtr<RenderElement> SVGSVGElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
    400400{
    401     if (isOutermostSVGSVGElement())
     401    if (isOutermostSVGSVGElement()) {
     402#if ENABLE(LAYER_BASED_SVG_ENGINE)
     403        if (document().settings().layerBasedSVGEngineEnabled())
     404            return createRenderer<RenderSVGRoot>(*this, WTFMove(style));
     405#endif
    402406        return createRenderer<LegacyRenderSVGRoot>(*this, WTFMove(style));
     407    }
    403408    return createRenderer<RenderSVGViewportContainer>(*this, WTFMove(style));
    404409}
Note: See TracChangeset for help on using the changeset viewer.