tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit e787eae82043d0ad011ca6b5f1691ebe4faf5158
parent 1e94bab72bde8214b27fc3cd45d2a814d77a555d
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Fri, 14 Nov 2025 01:36:02 +0000

Bug 1958206 - Allow subgrids to be containing blocks again. r=TYLin,layout-reviewers

Instead, ensure we end up with a reasonable containing block reflow
input for subgrid to avoid regressing the parent.

Differential Revision: https://phabricator.services.mozilla.com/D272370

Diffstat:
Mlayout/generic/ReflowInput.cpp | 20+++++++-------------
Mlayout/generic/nsIFrame.cpp | 5++---
Atesting/web-platform/tests/css/css-grid/subgrid/sticky-subgrid-item-ref.html | 11+++++++++++
Atesting/web-platform/tests/css/css-grid/subgrid/sticky-subgrid-item.html | 43+++++++++++++++++++++++++++++++++++++++++++
4 files changed, 63 insertions(+), 16 deletions(-)

diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp @@ -603,29 +603,23 @@ static bool MightBeContainingBlockFor(nsIFrame* aMaybeContainingBlock, } void ReflowInput::InitCBReflowInput() { - if (!mParentReflowInput) { - mCBReflowInput = nullptr; + mCBReflowInput = mParentReflowInput; + if (!mCBReflowInput || mParentReflowInput->mFlags.mDummyParentReflowInput) { return; } - if (mParentReflowInput->mFlags.mDummyParentReflowInput) { - mCBReflowInput = mParentReflowInput; - return; - } - // To avoid a long walk up the frame tree check if the parent frame can be a // containing block for mFrame. - if (MightBeContainingBlockFor(mParentReflowInput->mFrame, mFrame, + if (MightBeContainingBlockFor(mCBReflowInput->mFrame, mFrame, mStyleDisplay) && - mParentReflowInput->mFrame == - mFrame->GetContainingBlock(0, mStyleDisplay)) { + mCBReflowInput->mFrame == mFrame->GetContainingBlock(0, mStyleDisplay)) { // Inner table frames need to use the containing block of the outer // table frame. if (mFrame->IsTableFrame()) { + MOZ_ASSERT(mParentReflowInput->mCBReflowInput, + "Inner table frames shouldn't be reflow roots"); mCBReflowInput = mParentReflowInput->mCBReflowInput; - } else { - mCBReflowInput = mParentReflowInput; } - } else { + } else if (mParentReflowInput->mCBReflowInput) { mCBReflowInput = mParentReflowInput->mCBReflowInput; } } diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp @@ -8681,9 +8681,8 @@ bool nsIFrame::IsBlockContainer() const { // // If we ever start skipping table row groups from being containing blocks, // you need to remove the StickyScrollContainer hack referencing bug 1421660. - return !IsLineParticipant() && !IsBlockWrapper() && !IsSubgrid() && - // Table rows are not containing blocks either - !IsTableRowFrame(); + // Table rows are not containing blocks either + return !IsLineParticipant() && !IsBlockWrapper() && !IsTableRowFrame(); } nsIFrame* nsIFrame::GetContainingBlock( diff --git a/testing/web-platform/tests/css/css-grid/subgrid/sticky-subgrid-item-ref.html b/testing/web-platform/tests/css/css-grid/subgrid/sticky-subgrid-item-ref.html @@ -0,0 +1,11 @@ +<!doctype html> +<meta charset="utf-8"> +<title>sticky inside subgrid</title> +<style> +body { margin: 0 } +div { + border: 10px solid orange; + height: 400px; +} +</style> +<div></div> diff --git a/testing/web-platform/tests/css/css-grid/subgrid/sticky-subgrid-item.html b/testing/web-platform/tests/css/css-grid/subgrid/sticky-subgrid-item.html @@ -0,0 +1,43 @@ +<!doctype html> +<meta charset="utf-8"> +<title>sticky inside subgrid</title> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1958206"> +<link rel="help" href="https://drafts.csswg.org/css-grid-2"> +<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez"> +<link rel="author" href="https://mozilla.com" title="Mozilla"> +<link rel="match" href="sticky-subgrid-item-ref.html"> +<style> +:root { scrollbar-width: none } +body { margin: 0 } +.grid { + display: grid; + grid-template-columns: 1fr; + margin-bottom: 100vh; +} + +.subgrid { + border: 10px solid orange; + display: grid; + grid-template-columns: subgrid; + height: 400px; + margin-bottom: 100px; +} + +.sticky { + background: red; + position: sticky; + top: 10px; + height: 200px; +} +</style> +<div class="grid"> + <div class="subgrid"> + <div class="sticky"> + This should not be visible. + </div> + </div> + <div class="subgrid" id="target"></div> +</div> +<script> + target.scrollIntoView({ block: "start" }); +</script>