From 3285bbf67ee9a03b95ba37919bbb22a3a31c273f Mon Sep 17 00:00:00 2001 From: Ting-Yu Lin Date: Mon, 15 Nov 2021 18:51:29 +0000 Subject: [PATCH] Bug 1175509 Part 2 - Make TryLayout correctly consider ScrolledContentDependsOnBSize in vertical writing-mode. r=emilio This patch potentially changes the behavior when the scrolled frame is in vertical writing-mode, but it should be the correct way to handle the scrollbar change. Differential Revision: https://phabricator.services.mozilla.com/D130711 --- layout/generic/nsGfxScrollFrame.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index e265f4886cac..2e99e9b8d061 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -437,10 +437,23 @@ bool nsHTMLScrollFrame::TryLayout(ScrollReflowInput* aState, return false; } - if (aAssumeVScroll != aState->mReflowedContentsWithVScrollbar || - (aAssumeHScroll != aState->mReflowedContentsWithHScrollbar && - ScrolledContentDependsOnBSize(aState))) { - if (aAssumeHScroll != aState->mReflowedContentsWithHScrollbar) { + const bool assumeVScrollChanged = + aAssumeVScroll != aState->mReflowedContentsWithVScrollbar; + const bool assumeHScrollChanged = + aAssumeHScroll != aState->mReflowedContentsWithHScrollbar; + const bool isVertical = GetWritingMode().IsVertical(); + + const bool shouldReflowScolledFrame = [=]() { + if (isVertical) { + return assumeHScrollChanged || + (assumeVScrollChanged && ScrolledContentDependsOnBSize(aState)); + } + return assumeVScrollChanged || + (assumeHScrollChanged && ScrolledContentDependsOnBSize(aState)); + }(); + + if (shouldReflowScolledFrame) { + if (isVertical ? assumeVScrollChanged : assumeHScrollChanged) { nsLayoutUtils::MarkIntrinsicISizesDirtyIfDependentOnBSize( mHelper.mScrolledFrame); } @@ -644,9 +657,6 @@ bool nsHTMLScrollFrame::TryLayout(ScrollReflowInput* aState, return true; } -// XXX Height/BSize mismatch needs to be addressed here; check the caller! -// Currently this will only behave as expected for horizontal writing modes. -// (See bug 1175509.) bool nsHTMLScrollFrame::ScrolledContentDependsOnBSize( ScrollReflowInput* aState) const { return mHelper.mScrolledFrame->HasAnyStateBits(