Bug 1475033 part 4 - Implement scrollbar-width: none. r?mstange
MozReview-Commit-ID: 97AOILxYSw0
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1091,16 +1091,27 @@ nsHTMLScrollFrame::Reflow(nsPresContext*
mHelper.mCollapsedResizer = true;
Element* browserRoot = GetBrowserRoot(mContent);
if (browserRoot) {
bool showResizer = browserRoot->HasAttr(kNameSpaceID_None, nsGkAtoms::showresizer);
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.
+ ComputedStyle* scrollbarStyle = nsLayoutUtils::StyleForScrollbar(this);
+ auto scrollbarWidth = scrollbarStyle->StyleUIReset()->mScrollbarWidth;
+ if (scrollbarWidth == StyleScrollbarWidth::None) {
+ state.mVScrollbar = ShowScrollbar::Never;
+ state.mHScrollbar = ShowScrollbar::Never;
+ }
}
nsRect oldScrollAreaBounds = mHelper.mScrollPort;
nsRect oldScrolledAreaBounds =
mHelper.mScrolledFrame->GetScrollableOverflowRectRelativeToParent();
nsPoint oldScrollPosition = mHelper.GetScrollPosition();
state.mComputedBorder = aReflowInput.ComputedPhysicalBorderPadding() -
@@ -4657,19 +4668,25 @@ ScrollFrameHelper::CreateAnonymousConten
// 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 (mOuter->StyleUIReset()->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;
}