Skip to content
Permalink
Browse files
Ensure that the top layer is always anchored to the RenderView
https://bugs.webkit.org/show_bug.cgi?id=231292

Reviewed by Simon Fraser.

A fixed positioned block level box is not necessarily anchored to the RenderView (see canContainFixedPositionObjects).
This patch ensures that we skip those ancestors and return the RenderView as the containing block for the top layer content.

https://fullscreen.spec.whatwg.org/#new-stacking-layer
"If the top layer position property computes to fixed, its containing block is the viewport, and the initial containing block otherwise."

* rendering/RenderObject.cpp:
(WebCore::RenderObject::containingBlock const):
(WebCore::containerForElement):


Canonical link: https://commits.webkit.org/242585@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@283634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Oct 6, 2021
1 parent 18768b2 commit 4e1d3773915cfaff54c87e720011f4752ce94ff4
Showing 2 changed files with 22 additions and 2 deletions.
@@ -1,3 +1,20 @@
2021-10-06 Alan Bujtas <zalan@apple.com>

Ensure that the top layer is always anchored to the RenderView
https://bugs.webkit.org/show_bug.cgi?id=231292

Reviewed by Simon Fraser.

A fixed positioned block level box is not necessarily anchored to the RenderView (see canContainFixedPositionObjects).
This patch ensures that we skip those ancestors and return the RenderView as the containing block for the top layer content.

https://fullscreen.spec.whatwg.org/#new-stacking-layer
"If the top layer position property computes to fixed, its containing block is the viewport, and the initial containing block otherwise."

* rendering/RenderObject.cpp:
(WebCore::RenderObject::containingBlock const):
(WebCore::containerForElement):

2021-10-06 Tim Nguyen <ntim@apple.com>

Reset m_isModal flag when removing <dialog> from document
@@ -657,8 +657,9 @@ void RenderObject::setLayerNeedsFullRepaintForPositionedMovementLayout()

RenderBlock* RenderObject::containingBlock() const
{
auto containingBlockForRenderer = [](const RenderElement& renderer)
{
auto containingBlockForRenderer = [](const auto& renderer) -> RenderBlock* {
if (isInTopLayerOrBackdrop(renderer.style(), renderer.element()))
return &renderer.view();
if (renderer.isAbsolutelyPositioned())
return renderer.containingBlockForAbsolutePosition();
if (renderer.isFixedPositioned())
@@ -1468,6 +1469,8 @@ static inline RenderElement* containerForElement(const RenderObject& renderer, c
// This does mean that computePositionedLogicalWidth and computePositionedLogicalHeight have to use container().
if (!is<RenderElement>(renderer))
return renderer.parent();
if (isInTopLayerOrBackdrop(renderer.style(), downcast<RenderElement>(renderer).element()))
return &renderer.view();
auto position = renderer.style().position();
if (position == PositionType::Static || position == PositionType::Relative || position == PositionType::Sticky)
return renderer.parent();

0 comments on commit 4e1d377

Please sign in to comment.