tor-browser

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

commit dc41e70d999404af7dd06be9aef9633d54ee7109
parent 5d147cfe5a93ee29e74338485dabf45678eaedc8
Author: Cristina Horotan <chorotan@mozilla.com>
Date:   Thu, 18 Dec 2025 01:35:23 +0200

Revert "Bug 2006499 - Consider exposing active fallback style in getComputedStyle(). r=jwatt" for causing mochitest failures on nsComputedDOMStyle.cpp

This reverts commit 6572b7509a9036d73e396cee6b4b1e1f3c58623b.

Diffstat:
Mlayout/base/AnchorPositioningUtils.h | 1-
Mlayout/generic/AbsoluteContainingBlock.cpp | 23+++++++++++++----------
Mlayout/style/nsComputedDOMStyle.cpp | 42+++++++-----------------------------------
Mlayout/style/nsComputedDOMStyle.h | 4++--
Atesting/web-platform/meta/css/css-anchor-position/position-try-backdrop.html.ini | 3+++
Atesting/web-platform/meta/css/css-anchor-position/try-tactic-sizing.html.ini | 9+++++++++
6 files changed, 34 insertions(+), 48 deletions(-)

diff --git a/layout/base/AnchorPositioningUtils.h b/layout/base/AnchorPositioningUtils.h @@ -163,7 +163,6 @@ class AnchorPosReferenceData { }; struct LastSuccessfulPositionData { - RefPtr<const ComputedStyle> mStyle; uint32_t mIndex = 0; bool mTriedAllFallbacks = false; }; diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp @@ -1193,13 +1193,17 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame( Maybe<uint32_t> firstTryIndex; Maybe<nsPoint> firstTryNormalPosition; - const auto* lastSuccessfulPosition = - aKidFrame->GetProperty(nsIFrame::LastSuccessfulPositionFallback()); - if (lastSuccessfulPosition) { - if (!SeekFallbackTo(lastSuccessfulPosition->mIndex)) { - aKidFrame->RemoveProperty(nsIFrame::LastSuccessfulPositionFallback()); - } else { - firstTryIndex = Some(lastSuccessfulPosition->mIndex); + // TODO(emilio): Right now fallback only applies to position-area, which only + // makes a difference with a default anchor... Generalize it? + if (aAnchorPosResolutionCache) { + const auto* lastSuccessfulPosition = + aKidFrame->GetProperty(nsIFrame::LastSuccessfulPositionFallback()); + if (lastSuccessfulPosition) { + if (!SeekFallbackTo(lastSuccessfulPosition->mIndex)) { + aKidFrame->RemoveProperty(nsIFrame::LastSuccessfulPositionFallback()); + } else { + firstTryIndex = Some(lastSuccessfulPosition->mIndex); + } } } @@ -1603,9 +1607,8 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame( if (currentFallbackIndex) { aKidFrame->SetOrUpdateDeletableProperty( - nsIFrame::LastSuccessfulPositionFallback(), - LastSuccessfulPositionData{currentFallbackStyle, *currentFallbackIndex, - isOverflowingCB}); + nsIFrame::LastSuccessfulPositionFallback(), *currentFallbackIndex, + isOverflowingCB); } #ifdef DEBUG diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp @@ -10,7 +10,6 @@ #include <algorithm> -#include "AnchorPositioningUtils.h" #include "mozilla/AppUnits.h" #include "mozilla/ComputedStyle.h" #include "mozilla/ComputedStyleInlines.h" @@ -759,30 +758,26 @@ void nsComputedDOMStyle::ClearComputedStyle() { } void nsComputedDOMStyle::SetResolvedComputedStyle( - RefPtr<const ComputedStyle> aStyle, uint64_t aGeneration) { + RefPtr<const ComputedStyle>&& aContext, uint64_t aGeneration) { if (!mResolvedComputedStyle) { mResolvedComputedStyle = true; mElement->AddMutationObserver(this); } - mComputedStyle = std::move(aStyle); + mComputedStyle = aContext; mComputedStyleGeneration = aGeneration; mPresShellId = mPresShell->GetPresShellId(); } -void nsComputedDOMStyle::SetFrameComputedStyle( - RefPtr<const ComputedStyle> aStyle, uint64_t aGeneration) { +void nsComputedDOMStyle::SetFrameComputedStyle(mozilla::ComputedStyle* aStyle, + uint64_t aGeneration) { ClearComputedStyle(); - mComputedStyle = std::move(aStyle); + mComputedStyle = aStyle; mComputedStyleGeneration = aGeneration; mPresShellId = mPresShell->GetPresShellId(); } static bool MayNeedToFlushLayout(NonCustomCSSPropertyId aPropId) { switch (aPropId) { - case eCSSProperty_max_width: - case eCSSProperty_max_height: - case eCSSProperty_min_width: - case eCSSProperty_min_height: case eCSSProperty_width: case eCSSProperty_height: case eCSSProperty_block_size: @@ -887,11 +882,6 @@ static bool PaddingNeedsUsedValue(const LengthPercentage& aValue, return !aValue.ConvertsToLength() || aStyle.StyleDisplay()->HasAppearance(); } -static bool HasPositionFallbacks(nsIFrame* aFrame) { - return aFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW) && - !aFrame->StylePosition()->mPositionTryFallbacks._0.IsEmpty(); -} - bool nsComputedDOMStyle::NeedsToFlushLayout( NonCustomCSSPropertyId aPropId) const { MOZ_ASSERT(aPropId != eCSSProperty_UNKNOWN); @@ -909,18 +899,6 @@ bool nsComputedDOMStyle::NeedsToFlushLayout( } switch (aPropId) { - case eCSSProperty_max_width: - return HasPositionFallbacks(frame) || - frame->StylePosition()->mMaxWidth.HasAnchorPositioningFunction(); - case eCSSProperty_max_height: - return HasPositionFallbacks(frame) || - frame->StylePosition()->mMaxHeight.HasAnchorPositioningFunction(); - case eCSSProperty_min_width: - return HasPositionFallbacks(frame) || - frame->StylePosition()->mMinWidth.HasAnchorPositioningFunction(); - case eCSSProperty_min_height: - return HasPositionFallbacks(frame) || - frame->StylePosition()->mMinHeight.HasAnchorPositioningFunction(); case eCSSProperty_width: case eCSSProperty_height: return !IsNonReplacedInline(frame); @@ -963,8 +941,7 @@ bool nsComputedDOMStyle::NeedsToFlushLayout( // NOTE(dshin): Raw margin value access since we want to flush // anchor-dependent values here. Side side = SideForPaddingOrMarginOrInsetProperty(aPropId); - return !style->StyleMargin()->mMargin.Get(side).ConvertsToLength() || - HasPositionFallbacks(frame); + return !style->StyleMargin()->mMargin.Get(side).ConvertsToLength(); } default: return false; @@ -1080,12 +1057,7 @@ void nsComputedDOMStyle::UpdateCurrentStyleSources( mInnerFrame = mOuterFrame; if (mOuterFrame) { mInnerFrame = nsLayoutUtils::GetStyleFrame(mOuterFrame); - const auto* style = mInnerFrame->Style(); - if (auto* data = mInnerFrame->GetProperty( - nsIFrame::LastSuccessfulPositionFallback())) { - style = data->mStyle.get(); - } - SetFrameComputedStyle(std::move(style), currentGeneration); + SetFrameComputedStyle(mInnerFrame->Style(), currentGeneration); NS_ASSERTION(mComputedStyle, "Frame without style?"); } } diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h @@ -167,9 +167,9 @@ class nsComputedDOMStyle final : public nsDOMCSSDeclaration, // Helper functions called by UpdateCurrentStyleSources. void ClearComputedStyle(); - void SetResolvedComputedStyle(RefPtr<const ComputedStyle>, + void SetResolvedComputedStyle(RefPtr<const ComputedStyle>&& aContext, uint64_t aGeneration); - void SetFrameComputedStyle(RefPtr<const ComputedStyle>, uint64_t aGeneration); + void SetFrameComputedStyle(ComputedStyle* aStyle, uint64_t aGeneration); static already_AddRefed<const ComputedStyle> DoGetComputedStyleNoFlush( const Element*, const PseudoStyleRequest&, mozilla::PresShell*, diff --git a/testing/web-platform/meta/css/css-anchor-position/position-try-backdrop.html.ini b/testing/web-platform/meta/css/css-anchor-position/position-try-backdrop.html.ini @@ -0,0 +1,3 @@ +[position-try-backdrop.html] + [::backdrop can use position-try-fallbacks] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-anchor-position/try-tactic-sizing.html.ini b/testing/web-platform/meta/css/css-anchor-position/try-tactic-sizing.html.ini @@ -0,0 +1,9 @@ +[try-tactic-sizing.html] + [flip-block does not affect sizing] + expected: FAIL + + [flip-inline does not affect sizing] + expected: FAIL + + [flip-start affects sizing] + expected: FAIL