-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LBSE] Add RenderSVGResourceContainer
https://bugs.webkit.org/show_bug.cgi?id=261880 Reviewed by Nikolas Zimmermann. Add RenderSVGResourceContainer for LBSE which knows how to handle RenderLayer and will act for future LBSE specific SVG resources. Start keeping track of RenderSVGResourceContainer in ShadowRoot and adjust RenderObject to be able to distinguish between LBSE and legacy SVG resources. * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/dom/TreeScope.cpp: (WebCore::TreeScope::addSVGResource): (WebCore::TreeScope::removeSVGResource): (WebCore::TreeScope::svgResourceById const): * Source/WebCore/dom/TreeScope.h: * Source/WebCore/rendering/RenderObject.h: (WebCore::RenderObject::isLegacySVGResourceContainer const): * Source/WebCore/rendering/svg/RenderSVGHiddenContainer.cpp: (WebCore::RenderSVGHiddenContainer::RenderSVGHiddenContainer): * Source/WebCore/rendering/svg/RenderSVGHiddenContainer.h: (WebCore::RenderObject::isLegacySVGResourceContainer const): * Source/WebCore/rendering/svg/RenderSVGHiddenContainer.h: * Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp: Added. (WebCore::RenderSVGResourceContainer::RenderSVGResourceContainer): (WebCore::RenderSVGResourceContainer::willBeDestroyed): (WebCore::RenderSVGResourceContainer::styleDidChange): (WebCore::RenderSVGResourceContainer::idChanged): (WebCore::RenderSVGResourceContainer::registerResource): * Source/WebCore/rendering/svg/RenderSVGResourceContainer.h: Added. * Source/WebCore/rendering/svg/SVGResourcesCycleSolver.cpp: (WebCore::SVGResourcesCycleSolver::resourceContainsCycles): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceContainer.h: * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGPath.cpp: * Source/WebCore/svg/SVGDefsElement.cpp: (WebCore::SVGDefsElement::createElementRenderer): * Source/WebCore/svg/SVGGElement.cpp: (WebCore::SVGGElement::createElementRenderer): * Source/WebCore/svg/SVGSymbolElement.cpp: (WebCore::SVGSymbolElement::createElementRenderer): Canonical link: https://commits.webkit.org/269522@main
- Loading branch information
Showing
15 changed files
with
182 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (C) Research In Motion Limited 2010. All rights reserved. | ||
* Copyright (c) 2023 Igalia S.L. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public License | ||
* along with this library; see the file COPYING.LIB. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "RenderSVGResourceContainer.h" | ||
|
||
#include "RenderLayer.h" | ||
#include "RenderSVGRoot.h" | ||
#include "SVGElementTypeHelpers.h" | ||
#include "SVGResourcesCache.h" | ||
#include <wtf/IsoMallocInlines.h> | ||
#include <wtf/SetForScope.h> | ||
#include <wtf/StackStats.h> | ||
|
||
namespace WebCore { | ||
|
||
WTF_MAKE_ISO_ALLOCATED_IMPL(RenderSVGResourceContainer); | ||
|
||
RenderSVGResourceContainer::RenderSVGResourceContainer(Type type, SVGElement& element, RenderStyle&& style) | ||
: RenderSVGHiddenContainer(type, element, WTFMove(style)) | ||
, m_id(element.getIdAttribute()) | ||
{ | ||
} | ||
|
||
RenderSVGResourceContainer::~RenderSVGResourceContainer() = default; | ||
|
||
void RenderSVGResourceContainer::willBeDestroyed() | ||
{ | ||
if (m_registered) { | ||
treeScopeForSVGReferences().removeSVGResource(m_id); | ||
m_registered = false; | ||
} | ||
|
||
RenderSVGHiddenContainer::willBeDestroyed(); | ||
} | ||
|
||
void RenderSVGResourceContainer::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) | ||
{ | ||
RenderSVGHiddenContainer::styleDidChange(diff, oldStyle); | ||
|
||
if (!m_registered) { | ||
m_registered = true; | ||
registerResource(); | ||
} | ||
} | ||
|
||
void RenderSVGResourceContainer::idChanged() | ||
{ | ||
// Remove old id, that is guaranteed to be present in cache. | ||
treeScopeForSVGReferences().removeSVGResource(m_id); | ||
m_id = element().getIdAttribute(); | ||
|
||
registerResource(); | ||
} | ||
|
||
void RenderSVGResourceContainer::registerResource() | ||
{ | ||
auto& treeScope = this->treeScopeForSVGReferences(); | ||
if (!treeScope.isIdOfPendingSVGResource(m_id)) { | ||
treeScope.addSVGResource(m_id, *this); | ||
return; | ||
} | ||
|
||
auto elements = copyToVectorOf<Ref<SVGElement>>(treeScope.removePendingSVGResource(m_id)); | ||
|
||
treeScope.addSVGResource(m_id, *this); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) Research In Motion Limited 2010. All rights reserved. | ||
* Copyright (c) 2023 Igalia S.L. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Library General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Library General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Library General Public License | ||
* along with this library; see the file COPYING.LIB. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "RenderSVGHiddenContainer.h" | ||
#include "RenderSVGResource.h" | ||
|
||
namespace WebCore { | ||
|
||
class RenderLayer; | ||
|
||
class RenderSVGResourceContainer : public RenderSVGHiddenContainer, public RenderSVGResource { | ||
WTF_MAKE_ISO_ALLOCATED(RenderSVGResourceContainer); | ||
public: | ||
virtual ~RenderSVGResourceContainer(); | ||
|
||
void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; | ||
|
||
bool isSVGResourceContainer() const final { return true; } | ||
|
||
void idChanged(); | ||
|
||
protected: | ||
RenderSVGResourceContainer(Type, SVGElement&, RenderStyle&&); | ||
|
||
private: | ||
friend class SVGResourcesCache; | ||
void addClient(RenderElement&); | ||
void removeClient(RenderElement&); | ||
|
||
void willBeDestroyed() final; | ||
void registerResource(); | ||
|
||
AtomString m_id; | ||
bool m_registered { false }; | ||
}; | ||
|
||
} // namespace WebCore | ||
|
||
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGResourceContainer, isSVGResourceContainer()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters