From c05bca316875ca90c56468e70b54a355bd4ca3c6 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 8 Jan 2021 14:15:50 +0000 Subject: Issue #1705 - Part 5: Implement scrollbar-width:none for all target platforms. --- layout/generic/nsGfxScrollFrame.cpp | 39 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'layout') diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 8e7b208e4..d1053da86 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -1054,6 +1054,15 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext, reflowScrollCorner = showResizer == mHelper.mCollapsedResizer; mHelper.mCollapsedResizer = !showResizer; } + + // Hide the scrollbar when the scrollbar-width is set to none. + // This is only needed for root element because scrollbars of non- + // root elements with "scrollbar-width: none" is already suppressed + // in ScrollFrameHelper::CreateAnonymousContent. + if (this->StyleUserInterface()->mScrollbarWidth == StyleScrollbarWidth::None) { + state.mVScrollbar = ShowScrollbar::Never; + state.mHScrollbar = ShowScrollbar::Never; + } } nsRect oldScrollAreaBounds = mHelper.mScrollPort; @@ -4404,24 +4413,30 @@ ScrollFrameHelper::CreateAnonymousContent( nsIScrollableFrame *scrollable = do_QueryFrame(mOuter); - // If we're the scrollframe for the root, then we want to construct - // our scrollbar frames no matter what. That way later dynamic - // changes to propagated overflow styles will show or hide - // scrollbars on the viewport without requiring frame reconstruction - // of the viewport (good!). bool canHaveHorizontal; bool canHaveVertical; - if (!mIsRoot) { - ScrollStyles styles = scrollable->GetScrollStyles(); - canHaveHorizontal = styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN; - canHaveVertical = styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN; + if (mIsRoot) { + // If we're the scrollframe for the root, then we want to construct + // our scrollbar frames no matter what. That way, later dynamic + // changes to propagated overflow styles will show or hide + // scrollbars on the viewport without requiring frame reconstruction + // of the viewport (which is a Good Thing(tm)!). + canHaveHorizontal = true; + canHaveVertical = true; + } else { + if (mOuter->StyleUserInterface()->mScrollbarWidth == StyleScrollbarWidth::None) { + // If scrollbar-width is none, don't generate scrollbars. + canHaveHorizontal = false; + canHaveVertical = false; + } else { + ScrollStyles styles = scrollable->GetScrollStyles(); + canHaveHorizontal = styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN; + canHaveVertical = styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN; + } if (!canHaveHorizontal && !canHaveVertical && !isResizable) { // Nothing to do. return NS_OK; } - } else { - canHaveHorizontal = true; - canHaveVertical = true; } // The anonymous
used by never gets scrollbars. -- cgit v1.2.3