Skip to content
Permalink
Browse files
Take top layers into account in addLayers/removeLayers
https://bugs.webkit.org/show_bug.cgi?id=238946

Patch by Rob Buis <rbuis@igalia.com> on 2022-04-08
Reviewed by Simon Fraser.

Take top layers into account in addLayers/removeLayers, they
should use the RenderView layer as parent (emulating layerParent).

* rendering/RenderElement.cpp:
(WebCore::addLayers):
(WebCore::RenderElement::addLayers):
(WebCore::RenderElement::removeLayers):
(WebCore::RenderElement::willBeRemovedFromTree):
* rendering/RenderElement.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects const):

Canonical link: https://commits.webkit.org/249429@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292596 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rwlbuis authored and webkit-commit-queue committed Apr 8, 2022
1 parent c7f59d7 commit 17b62691fb4b01ac988eadb2fc246a2bd0be8f2b
Showing 4 changed files with 36 additions and 17 deletions.
@@ -1,3 +1,22 @@
2022-04-08 Rob Buis <rbuis@igalia.com>

Take top layers into account in addLayers/removeLayers
https://bugs.webkit.org/show_bug.cgi?id=238946

Reviewed by Simon Fraser.

Take top layers into account in addLayers/removeLayers, they
should use the RenderView layer as parent (emulating layerParent).

* rendering/RenderElement.cpp:
(WebCore::addLayers):
(WebCore::RenderElement::addLayers):
(WebCore::RenderElement::removeLayers):
(WebCore::RenderElement::willBeRemovedFromTree):
* rendering/RenderElement.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects const):

2022-04-07 Antti Koivisto <antti@apple.com>

[CSS Container Queries] Evaluate against shadow-including ancestors
@@ -639,31 +639,31 @@ static RenderLayer* layerNextSiblingRespectingTopLayer(const RenderElement& rend
return findNextLayer(*renderer.parent(), parentLayer, &renderer);
}

static void addLayers(const RenderElement& addedRenderer, RenderElement& currentRenderer, RenderLayer& parentLayer, std::optional<RenderLayer*>& beforeChild)
static void addLayers(const RenderElement& addedRenderer, RenderElement& currentRenderer, RenderLayer* parentLayer)
{
if (currentRenderer.hasLayer()) {
if (!beforeChild.has_value())
beforeChild = layerNextSiblingRespectingTopLayer(addedRenderer, parentLayer);

parentLayer.addChild(*downcast<RenderLayerModelObject>(currentRenderer).layer(), beforeChild.value());
if (isInTopLayerOrBackdrop(currentRenderer.style(), currentRenderer.element()))
parentLayer = addedRenderer.view().layer();
RenderLayer* beforeChild = layerNextSiblingRespectingTopLayer(addedRenderer, *parentLayer);
parentLayer->addChild(*downcast<RenderLayerModelObject>(currentRenderer).layer(), beforeChild);
return;
}

for (auto& child : childrenOfType<RenderElement>(currentRenderer))
addLayers(addedRenderer, child, parentLayer, beforeChild);
addLayers(addedRenderer, child, parentLayer);
}

void RenderElement::addLayers(RenderLayer* parentLayer)
{
if (!parentLayer)
return;

std::optional<RenderLayer*> beforeChild;
WebCore::addLayers(*this, *this, *parentLayer, beforeChild);
WebCore::addLayers(*this, *this, parentLayer);
}

void RenderElement::removeLayers(RenderLayer* parentLayer)
void RenderElement::removeLayers()
{
RenderLayer* parentLayer = layerParent();
if (!parentLayer)
return;

@@ -673,7 +673,7 @@ void RenderElement::removeLayers(RenderLayer* parentLayer)
}

for (auto& child : childrenOfType<RenderElement>(*this))
child.removeLayers(parentLayer);
child.removeLayers();
}

void RenderElement::moveLayers(RenderLayer* oldParent, RenderLayer& newParent)
@@ -965,10 +965,8 @@ void RenderElement::willBeRemovedFromTree(IsInternalMove isInternalMove)
enclosingLayer->dirtyVisibleContentStatus();
}
// Keep our layer hierarchy updated.
if (firstChild() || hasLayer()) {
auto* parentLayer = layerParent();
removeLayers(parentLayer);
}
if (firstChild() || hasLayer())
removeLayers();

if (isOutOfFlowPositioned() && parent()->childrenInline())
parent()->dirtyLinesFromChangedChild(*this);
@@ -111,7 +111,7 @@ class RenderElement : public RenderObject {
RenderLayer* layerParent() const;
RenderLayer* layerNextSibling(RenderLayer& parentLayer) const;
void addLayers(RenderLayer* parentLayer);
void removeLayers(RenderLayer* parentLayer);
void removeLayers();
void moveLayers(RenderLayer* oldParent, RenderLayer& newParent);

virtual void dirtyLinesFromChangedChild(RenderObject&) { }
@@ -5572,8 +5572,10 @@ void RenderLayer::createReflection()

void RenderLayer::removeReflection()
{
if (!m_reflection->renderTreeBeingDestroyed())
m_reflection->removeLayers(this);
if (!m_reflection->renderTreeBeingDestroyed()) {
if (auto* layer = m_reflection->layer())
removeChild(*layer);
}

m_reflection->setParent(nullptr);
m_reflection = nullptr;

0 comments on commit 17b6269

Please sign in to comment.