Skip to content

Commit

Permalink
[macOS] Safari flashes a page background colored bar with top content…
Browse files Browse the repository at this point in the history
… inset dimensions in footer when window resizing

https://bugs.webkit.org/show_bug.cgi?id=274831
rdar://128940179

Reviewed by Simon Fraser.

Previously, on a FrameView resize, RenderLayerCompositor was sizing its
overhang area layer incorrectly since it did not account for the top
content offset. This is incorrect because the layer itself was
positioned vertically at the top content offset, so with the inflated
size, we always had a page background colored bar hanging at the bottom
of the frame, which was easily perceptible when snap resizing a Safari
window, for example.

This patch fixes said issue by introducing a reusable utility method
RenderLayerCompositor::updateSizeAndPositionForOverhangAreaLayer() that
is used both during layer creation and any later updates (such as when a
frame view's size changes). We make sure to size the layer (and
position it) correctly in this method, accounting for the top content
offset.

* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):
(WebCore::RenderLayerCompositor::updateSizeAndPositionForOverhangAreaLayer):
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
* Source/WebCore/rendering/RenderLayerCompositor.h:

Canonical link: https://commits.webkit.org/279562@main
  • Loading branch information
aprotyas committed May 31, 2024
1 parent 7e5e04b commit 071943e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
27 changes: 17 additions & 10 deletions Source/WebCore/rendering/RenderLayerCompositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2470,11 +2470,7 @@ void RenderLayerCompositor::frameViewDidChangeSize()
updateOverflowControlsLayers();

#if HAVE(RUBBER_BANDING)
if (m_layerForOverhangAreas) {
auto& frameView = m_renderView.frameView();
m_layerForOverhangAreas->setSize(frameView.frameRect().size());
m_layerForOverhangAreas->setPosition(FloatPoint(0, frameView.topContentInset()));
}
updateSizeAndPositionForOverhangAreaLayer();
#endif
}
}
Expand Down Expand Up @@ -4481,6 +4477,21 @@ void RenderLayerCompositor::rootBackgroundColorOrTransparencyChanged()
rootLayerConfigurationChanged();
}

#if HAVE(RUBBER_BANDING)
void RenderLayerCompositor::updateSizeAndPositionForOverhangAreaLayer()
{
if (!m_layerForOverhangAreas)
return;

float topContentInset = m_renderView.frameView().topContentInset();
IntSize overhangAreaSize = m_renderView.frameView().frameRect().size();
overhangAreaSize.contract(0, topContentInset);
overhangAreaSize.clampNegativeToZero();
m_layerForOverhangAreas->setSize(overhangAreaSize);
m_layerForOverhangAreas->setPosition({ 0, topContentInset });
}
#endif

void RenderLayerCompositor::updateOverflowControlsLayers()
{
#if HAVE(RUBBER_BANDING)
Expand All @@ -4490,11 +4501,7 @@ void RenderLayerCompositor::updateOverflowControlsLayers()
m_layerForOverhangAreas->setName(MAKE_STATIC_STRING_IMPL("overhang areas"));
m_layerForOverhangAreas->setDrawsContent(false);

float topContentInset = m_renderView.frameView().topContentInset();
IntSize overhangAreaSize = m_renderView.frameView().frameRect().size();
overhangAreaSize.setHeight(overhangAreaSize.height() - topContentInset);
m_layerForOverhangAreas->setSize(overhangAreaSize);
m_layerForOverhangAreas->setPosition(FloatPoint(0, topContentInset));
updateSizeAndPositionForOverhangAreaLayer();
m_layerForOverhangAreas->setAnchorPoint(FloatPoint3D());
updateLayerForOverhangAreasBackgroundColor();

Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/rendering/RenderLayerCompositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ class RenderLayerCompositor final : public GraphicsLayerClient {
GraphicsLayer* updateLayerForFooter(bool wantsLayer);

void updateLayerForOverhangAreasBackgroundColor();
void updateSizeAndPositionForOverhangAreaLayer();
#endif // HAVE(RUBBER_BANDING)

// FIXME: make the coordinated/async terminology consistent.
Expand Down

0 comments on commit 071943e

Please sign in to comment.