diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index c8760b8de327..1a6c901a34b1 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -1277,8 +1277,8 @@ bool KeyframeEffect::CanThrottleOverflowChangesInScrollable( } ScrollStyles ss = scrollable->GetScrollStyles(); - if (ss.mVertical == NS_STYLE_OVERFLOW_HIDDEN && - ss.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN && + if (ss.mVertical == StyleOverflow::Hidden && + ss.mHorizontal == StyleOverflow::Hidden && scrollable->GetLogicalScrollPosition() == nsPoint(0, 0)) { return true; } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 0f047107f641..e60a50c85707 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -6995,7 +6995,7 @@ void nsIDocument::UpdateViewportOverflowType(nscoord aScrolledWidth, MOZ_ASSERT(mPresShell); nsPresContext* pc = GetPresContext(); MOZ_ASSERT(pc->GetViewportScrollStylesOverride().mHorizontal == - NS_STYLE_OVERFLOW_HIDDEN, + StyleOverflow::Hidden, "Should only be called when viewport has overflow-x: hidden"); MOZ_ASSERT(aScrolledWidth > aScrollportWidth, "Should only be called when viewport is overflowed"); @@ -9317,15 +9317,15 @@ bool nsIDocument::IsPotentiallyScrollable(HTMLBodyElement* aBody) { MOZ_ASSERT(aBody->GetParent() == aBody->OwnerDoc()->GetRootElement()); nsIFrame* parentFrame = aBody->GetParent()->GetPrimaryFrame(); if (parentFrame && - parentFrame->StyleDisplay()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE && - parentFrame->StyleDisplay()->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE) { + parentFrame->StyleDisplay()->mOverflowX == StyleOverflow::Visible && + parentFrame->StyleDisplay()->mOverflowY == StyleOverflow::Visible) { return false; } // The element's used value of the overflow-x or overflow-y properties is not // visible. - if (bodyFrame->StyleDisplay()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE && - bodyFrame->StyleDisplay()->mOverflowY == NS_STYLE_OVERFLOW_VISIBLE) { + if (bodyFrame->StyleDisplay()->mOverflowX == StyleOverflow::Visible && + bodyFrame->StyleDisplay()->mOverflowY == StyleOverflow::Visible) { return false; } diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index f7eb98bbf24a..2ae6219c46da 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -2476,8 +2476,8 @@ nsIFrame* EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent( } ScrollStyles ss = scrollableFrame->GetScrollStyles(); - bool hiddenForV = (NS_STYLE_OVERFLOW_HIDDEN == ss.mVertical); - bool hiddenForH = (NS_STYLE_OVERFLOW_HIDDEN == ss.mHorizontal); + bool hiddenForV = (StyleOverflow::Hidden == ss.mVertical); + bool hiddenForH = (StyleOverflow::Hidden == ss.mHorizontal); if ((hiddenForV && hiddenForH) || (checkIfScrollableY && !checkIfScrollableX && hiddenForV) || (checkIfScrollableX && !checkIfScrollableY && hiddenForH)) { @@ -2585,10 +2585,10 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame, // Don't scroll around the axis whose overflow style is hidden. ScrollStyles overflowStyle = aScrollableFrame->GetScrollStyles(); - if (overflowStyle.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) { + if (overflowStyle.mHorizontal == StyleOverflow::Hidden) { actualDevPixelScrollAmount.x = 0; } - if (overflowStyle.mVertical == NS_STYLE_OVERFLOW_HIDDEN) { + if (overflowStyle.mVertical == StyleOverflow::Hidden) { actualDevPixelScrollAmount.y = 0; } @@ -2688,15 +2688,13 @@ void EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame, // additional action such as moving history. In such case, overflowDelta // values should stay zero. if (scrollFrameWeak.IsAlive()) { - if (aEvent->mDeltaX && - overflowStyle.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN && + if (aEvent->mDeltaX && overflowStyle.mHorizontal == StyleOverflow::Hidden && !ComputeScrollTargetAndMayAdjustWheelEvent( scrollFrame, aEvent, COMPUTE_SCROLLABLE_ANCESTOR_ALONG_X_AXIS_WITH_AUTO_DIR)) { aEvent->mOverflowDeltaX = aEvent->mDeltaX; } - if (aEvent->mDeltaY && - overflowStyle.mVertical == NS_STYLE_OVERFLOW_HIDDEN && + if (aEvent->mDeltaY && overflowStyle.mVertical == StyleOverflow::Hidden && !ComputeScrollTargetAndMayAdjustWheelEvent( scrollFrame, aEvent, COMPUTE_SCROLLABLE_ANCESTOR_ALONG_Y_AXIS_WITH_AUTO_DIR)) { diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 09046c94a70e..8b20322d964a 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -121,7 +121,7 @@ static CSSPoint ScrollFrameTo(nsIScrollableFrame* aFrame, // overflow:hidden (that is, we take |targetScrollPosition|). If this turns // out to be problematic, an alternative solution would be to ignore the // scroll position change (that is, use |geckoScrollPosition|). - if (aFrame->GetScrollStyles().mVertical == NS_STYLE_OVERFLOW_HIDDEN && + if (aFrame->GetScrollStyles().mVertical == StyleOverflow::Hidden && targetScrollPosition.y != geckoScrollPosition.y) { NS_WARNING( nsPrintfCString( @@ -129,7 +129,7 @@ static CSSPoint ScrollFrameTo(nsIScrollableFrame* aFrame, targetScrollPosition.y, geckoScrollPosition.y) .get()); } - if (aFrame->GetScrollStyles().mHorizontal == NS_STYLE_OVERFLOW_HIDDEN && + if (aFrame->GetScrollStyles().mHorizontal == StyleOverflow::Hidden && targetScrollPosition.x != geckoScrollPosition.x) { NS_WARNING( nsPrintfCString( diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index bb9916267fe7..1fa2031e9741 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -3264,7 +3264,7 @@ static void ScrollToShowRect(nsIScrollableFrame* aFrameAsScrollable, uint32_t directions = aFrameAsScrollable->GetPerceivedScrollingDirections(); if (((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) || - ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN) && + ss.mVertical != StyleOverflow::Hidden) && (!aVertical.mOnlyIfPerceivedScrollableDirection || (directions & nsIScrollableFrame::VERTICAL))) { if (ComputeNeedToScroll(aVertical.mWhenToScroll, lineSize.height, aRect.y, @@ -3280,7 +3280,7 @@ static void ScrollToShowRect(nsIScrollableFrame* aFrameAsScrollable, } if (((aFlags & nsIPresShell::SCROLL_OVERFLOW_HIDDEN) || - ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) && + ss.mHorizontal != StyleOverflow::Hidden) && (!aHorizontal.mOnlyIfPerceivedScrollableDirection || (directions & nsIScrollableFrame::HORIZONTAL))) { if (ComputeNeedToScroll(aHorizontal.mWhenToScroll, lineSize.width, aRect.x, diff --git a/layout/base/ScrollStyles.cpp b/layout/base/ScrollStyles.cpp index 2b8f45356f5a..12c34154121e 100644 --- a/layout/base/ScrollStyles.cpp +++ b/layout/base/ScrollStyles.cpp @@ -9,7 +9,7 @@ namespace mozilla { -ScrollStyles::ScrollStyles(uint8_t aH, uint8_t aV, +ScrollStyles::ScrollStyles(StyleOverflow aH, StyleOverflow aV, const nsStyleDisplay* aDisplay) : mHorizontal(aH), mVertical(aV), diff --git a/layout/base/ScrollStyles.h b/layout/base/ScrollStyles.h index c12b554ac67b..30c6ebc23a74 100644 --- a/layout/base/ScrollStyles.h +++ b/layout/base/ScrollStyles.h @@ -18,30 +18,29 @@ struct nsStyleDisplay; namespace mozilla { struct ScrollStyles { - // Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN, - // or NS_STYLE_OVERFLOW_AUTO. - uint8_t mHorizontal; - uint8_t mVertical; + // Always one of Scroll, Hidden, or Auto + StyleOverflow mHorizontal; + StyleOverflow mVertical; // Always one of NS_STYLE_SCROLL_BEHAVIOR_AUTO or // NS_STYLE_SCROLL_BEHAVIOR_SMOOTH uint8_t mScrollBehavior; - mozilla::StyleOverscrollBehavior mOverscrollBehaviorX; - mozilla::StyleOverscrollBehavior mOverscrollBehaviorY; - mozilla::StyleScrollSnapType mScrollSnapTypeX; - mozilla::StyleScrollSnapType mScrollSnapTypeY; + StyleOverscrollBehavior mOverscrollBehaviorX; + StyleOverscrollBehavior mOverscrollBehaviorY; + StyleScrollSnapType mScrollSnapTypeX; + StyleScrollSnapType mScrollSnapTypeY; nsStyleCoord mScrollSnapPointsX; nsStyleCoord mScrollSnapPointsY; nsStyleCoord::CalcValue mScrollSnapDestinationX; nsStyleCoord::CalcValue mScrollSnapDestinationY; - ScrollStyles(uint8_t aH, uint8_t aV) + ScrollStyles(StyleOverflow aH, StyleOverflow aV) : mHorizontal(aH), mVertical(aV), mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO), mOverscrollBehaviorX(StyleOverscrollBehavior::Auto), mOverscrollBehaviorY(StyleOverscrollBehavior::Auto), - mScrollSnapTypeX(mozilla::StyleScrollSnapType::None), - mScrollSnapTypeY(mozilla::StyleScrollSnapType::None), + mScrollSnapTypeX(StyleScrollSnapType::None), + mScrollSnapTypeY(StyleScrollSnapType::None), mScrollSnapPointsX(nsStyleCoord(eStyleUnit_None)), mScrollSnapPointsY(nsStyleCoord(eStyleUnit_None)) { mScrollSnapDestinationX.mPercent = 0; @@ -53,7 +52,7 @@ struct ScrollStyles { } explicit ScrollStyles(const nsStyleDisplay* aDisplay); - ScrollStyles(uint8_t aH, uint8_t aV, const nsStyleDisplay* aDisplay); + ScrollStyles(StyleOverflow aH, StyleOverflow aV, const nsStyleDisplay*); bool operator==(const ScrollStyles& aStyles) const { return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical && @@ -71,8 +70,8 @@ struct ScrollStyles { return !(*this == aStyles); } bool IsHiddenInBothDirections() const { - return mHorizontal == NS_STYLE_OVERFLOW_HIDDEN && - mVertical == NS_STYLE_OVERFLOW_HIDDEN; + return mHorizontal == StyleOverflow::Hidden && + mVertical == StyleOverflow::Hidden; } bool IsSmoothScroll(dom::ScrollBehavior aBehavior) const { return aBehavior == dom::ScrollBehavior::Smooth || diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 10af5c03dab9..7cf4d0535419 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -1827,9 +1827,9 @@ nsIScrollableFrame* nsLayoutUtils::GetNearestScrollableFrameForDirection( ScrollStyles ss = scrollableFrame->GetScrollStyles(); uint32_t directions = scrollableFrame->GetPerceivedScrollingDirections(); if (aDirection == eVertical - ? (ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN && + ? (ss.mVertical != StyleOverflow::Hidden && (directions & nsIScrollableFrame::VERTICAL)) - : (ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN && + : (ss.mHorizontal != StyleOverflow::Hidden && (directions & nsIScrollableFrame::HORIZONTAL))) return scrollableFrame; } @@ -1854,8 +1854,8 @@ nsIScrollableFrame* nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame, } else { ScrollStyles ss = scrollableFrame->GetScrollStyles(); if ((aFlags & SCROLLABLE_INCLUDE_HIDDEN) || - ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN || - ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) { + ss.mVertical != StyleOverflow::Hidden || + ss.mHorizontal != StyleOverflow::Hidden) { return scrollableFrame; } } @@ -5386,7 +5386,7 @@ static void AddStateBitToAncestors(nsIFrame* aFrame, nsFrameState aBit) { nscoord* fixedMinSize = nullptr; auto minSizeUnit = size.GetUnit(); if (minSizeUnit == eStyleUnit_Auto) { - if (aFrame->StyleDisplay()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE) { + if (aFrame->StyleDisplay()->mOverflowX == StyleOverflow::Visible) { size = aAxis == eAxisHorizontal ? stylePos->mWidth : stylePos->mHeight; // This is same as above: keywords should behaves as property's initial // values in block axis. @@ -8339,12 +8339,12 @@ nsLayoutUtils::ScrollbarAreaToExcludeFromCompositionBoundsFor( nsPoint scrollPosition = aScrollableFrame->GetScrollPosition(); if (aScrollableFrame->GetScrollStyles().mVertical == - NS_STYLE_OVERFLOW_HIDDEN) { + StyleOverflow::Hidden) { contentBounds.y = scrollPosition.y; contentBounds.height = 0; } if (aScrollableFrame->GetScrollStyles().mHorizontal == - NS_STYLE_OVERFLOW_HIDDEN) { + StyleOverflow::Hidden) { contentBounds.x = scrollPosition.x; contentBounds.width = 0; } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 3cb15d2d036d..81ad2d640988 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -193,7 +193,7 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType) mFocusTextColor(mDefaultColor), mBodyTextColor(mDefaultColor), mViewportScrollOverrideElement(nullptr), - mViewportScrollStyles(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO), + mViewportScrollStyles(StyleOverflow::Auto, StyleOverflow::Auto), mFocusRingWidth(1), mExistThrottledUpdates(false), // mImageAnimationMode is initialised below, in constructor body @@ -1240,7 +1240,7 @@ gfxSize nsPresContext::ScreenSizeInchesForFontInflation(bool* aChanged) { static bool CheckOverflow(const nsStyleDisplay* aDisplay, ScrollStyles* aStyles) { - if (aDisplay->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE && + if (aDisplay->mOverflowX == StyleOverflow::Visible && aDisplay->mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_AUTO && aDisplay->mOverscrollBehaviorX == StyleOverscrollBehavior::Auto && aDisplay->mOverscrollBehaviorY == StyleOverscrollBehavior::Auto && @@ -1255,9 +1255,9 @@ static bool CheckOverflow(const nsStyleDisplay* aDisplay, return false; } - if (aDisplay->mOverflowX == NS_STYLE_OVERFLOW_CLIP) { - *aStyles = ScrollStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN, - aDisplay); + if (aDisplay->mOverflowX == StyleOverflow::MozHiddenUnscrollable) { + *aStyles = + ScrollStyles(StyleOverflow::Hidden, StyleOverflow::Hidden, aDisplay); } else { *aStyles = ScrollStyles(aDisplay); } @@ -1315,7 +1315,7 @@ static Element* GetPropagatedScrollStylesForViewport( Element* nsPresContext::UpdateViewportScrollStylesOverride() { // Start off with our default styles, and then update them as needed. mViewportScrollStyles = - ScrollStyles(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO); + ScrollStyles(StyleOverflow::Auto, StyleOverflow::Auto); mViewportScrollOverrideElement = nullptr; // Don't propagate the scrollbar state in printing or print preview. if (!IsPaginated()) { @@ -1333,7 +1333,7 @@ Element* nsPresContext::UpdateViewportScrollStylesOverride() { if (fullscreenElement != document->GetRootElement() && fullscreenElement != mViewportScrollOverrideElement) { mViewportScrollStyles = - ScrollStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN); + ScrollStyles(StyleOverflow::Hidden, StyleOverflow::Hidden); } } return mViewportScrollOverrideElement; @@ -1351,7 +1351,7 @@ bool nsPresContext::ElementWouldPropagateScrollStyles(const Element& aElement) { // but saves us having to have more complicated code or more code duplication; // in practice we will make this call quite rarely, because we checked for all // the common cases above. - ScrollStyles dummy(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO); + ScrollStyles dummy(StyleOverflow::Auto, StyleOverflow::Auto); return GetPropagatedScrollStylesForViewport(this, &dummy) == &aElement; } diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 8a983c45052a..5d955010ad10 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -72,7 +72,7 @@ nsresult nsHTMLButtonControlFrame::HandleEvent(nsPresContext* aPresContext, } bool nsHTMLButtonControlFrame::ShouldClipPaintingToBorderBox() { - return IsInput() || StyleDisplay()->mOverflowX != NS_STYLE_OVERFLOW_VISIBLE; + return IsInput() || StyleDisplay()->mOverflowX != StyleOverflow::Visible; } void nsHTMLButtonControlFrame::BuildDisplayList( diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 3c34ed830349..eb3365b3532f 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -602,12 +602,11 @@ void nsListControlFrame::ReflowAsDropdown(nsPresContext* aPresContext, ScrollStyles nsListControlFrame::GetScrollStyles() const { // We can't express this in the style system yet; when we can, this can go // away and GetScrollStyles can be devirtualized - int32_t style = - IsInDropDownMode() ? NS_STYLE_OVERFLOW_AUTO : NS_STYLE_OVERFLOW_SCROLL; + auto style = IsInDropDownMode() ? StyleOverflow::Auto : StyleOverflow::Scroll; if (GetWritingMode().IsVertical()) { - return ScrollStyles(style, NS_STYLE_OVERFLOW_HIDDEN); + return ScrollStyles(style, StyleOverflow::Hidden); } else { - return ScrollStyles(NS_STYLE_OVERFLOW_HIDDEN, style); + return ScrollStyles(StyleOverflow::Hidden, style); } } diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 80caca56a5b6..8cfa8939c2ce 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -443,11 +443,11 @@ nsresult nsTextControlFrame::CreateRootNode() { if (!IsSingleLineTextControl()) { // We can't just inherit the overflow because setting visible overflow will // crash when the number of lines exceeds the height of the textarea and - // setting -moz-hidden-unscrollable overflow (NS_STYLE_OVERFLOW_CLIP) - // doesn't paint the caret for some reason. + // setting -moz-hidden-unscrollable overflow doesn't paint the caret for + // some reason. const nsStyleDisplay* disp = StyleDisplay(); - if (disp->mOverflowX != NS_STYLE_OVERFLOW_VISIBLE && - disp->mOverflowX != NS_STYLE_OVERFLOW_CLIP) { + if (disp->mOverflowX != StyleOverflow::Visible && + disp->mOverflowX != StyleOverflow::MozHiddenUnscrollable) { classValue.AppendLiteral(" inherit-overflow"); } } diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index f57aab452755..e3c2b2925789 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -407,7 +407,7 @@ void ReflowInput::Init(nsPresContext* aPresContext, nsIFrame* parent = mFrame->GetParent(); if (parent && (parent->GetStateBits() & NS_FRAME_IN_CONSTRAINED_BSIZE) && !(parent->IsScrollFrame() && - parent->StyleDisplay()->mOverflowY != NS_STYLE_OVERFLOW_HIDDEN)) { + parent->StyleDisplay()->mOverflowY != StyleOverflow::Hidden)) { mFrame->AddStateBits(NS_FRAME_IN_CONSTRAINED_BSIZE); } else if (type == LayoutFrameType::SVGForeignObject) { // An SVG foreignObject frame is inherently constrained block-size. diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 946995b0dc6d..9d6840de4f75 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -102,7 +102,7 @@ static bool IsInlineAxisOverflowVisible(nsIFrame* aFrame) { auto overflow = aFrame->GetWritingMode().IsVertical() ? f->StyleDisplay()->mOverflowY : f->StyleDisplay()->mOverflowX; - return overflow == NS_STYLE_OVERFLOW_VISIBLE; + return overflow == StyleOverflow::Visible; } static void ClipMarker(const nsRect& aContentArea, const nsRect& aMarkerRect, @@ -314,7 +314,7 @@ TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder, auto scrollbarStyle = mBlockWM.IsVertical() ? mScrollableFrame->GetScrollStyles().mVertical : mScrollableFrame->GetScrollStyles().mHorizontal; - mCanHaveInlineAxisScrollbar = scrollbarStyle != NS_STYLE_OVERFLOW_HIDDEN; + mCanHaveInlineAxisScrollbar = scrollbarStyle != StyleOverflow::Hidden; if (!mAdjustForPixelSnapping) { // Scrolling to the end position can leave some text still overflowing due // to pixel snapping behaviour in our scrolling code. diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 04fa2b648013..1e5ab1556e78 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -2036,7 +2036,7 @@ void FlexItem::CheckForMinSizeAuto(const ReflowInput& aFlexItemReflowInput, // non-'visible' due to the way the subproperties interact. mNeedsMinSizeAutoResolution = IsAutoOrEnumOnBSize(mainMinSize, IsInlineAxisMainAxis()) && - disp->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE; + disp->mOverflowX == StyleOverflow::Visible; } nscoord FlexItem::GetBaselineOffsetFromOuterCrossEdge( diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 33ab05e55fad..4a5046576cf4 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -8895,8 +8895,8 @@ bool nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas, // children are actually clipped to the padding-box, but since the // overflow area should include the entire border-box, just set it to // the border-box here. - NS_ASSERTION((disp->mOverflowY == NS_STYLE_OVERFLOW_CLIP) == - (disp->mOverflowX == NS_STYLE_OVERFLOW_CLIP), + NS_ASSERTION((disp->mOverflowY == StyleOverflow::MozHiddenUnscrollable) == + (disp->mOverflowX == StyleOverflow::MozHiddenUnscrollable), "If one overflow is clip, the other should be too"); if (applyOverflowClipping) { // The contents are actually clipped to the padding area @@ -8917,8 +8917,8 @@ bool nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas, } } - // Note that NS_STYLE_OVERFLOW_CLIP doesn't clip the frame background, - // so we add theme background overflow here so it's not clipped. + // Note that StyleOverflow::MozHiddenUnscrollable doesn't clip the frame + // background, so we add theme background overflow here so it's not clipped. if (!::IsXULBoxWrapped(this) && IsThemed(disp)) { nsRect r(bounds); nsPresContext* presContext = PresContext(); diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index 183e9c4fb05e..3c662795e373 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -588,7 +588,8 @@ class nsFrame : public nsBox { const nsStyleDisplay* aDisp) { // clip overflow:-moz-hidden-unscrollable, except for nsListControlFrame, // which is an nsHTMLScrollFrame. - if (MOZ_UNLIKELY(aDisp->mOverflowX == NS_STYLE_OVERFLOW_CLIP && + if (MOZ_UNLIKELY(aDisp->mOverflowX == + mozilla::StyleOverflow::MozHiddenUnscrollable && !aFrame->IsListControlFrame())) { return true; } @@ -603,8 +604,8 @@ class nsFrame : public nsBox { } // and overflow:hidden that we should interpret as -moz-hidden-unscrollable - if (aDisp->mOverflowX == NS_STYLE_OVERFLOW_HIDDEN && - aDisp->mOverflowY == NS_STYLE_OVERFLOW_HIDDEN) { + if (aDisp->mOverflowX == mozilla::StyleOverflow::Hidden && + aDisp->mOverflowY == mozilla::StyleOverflow::Hidden) { // REVIEW: these are the frame types that set up clipping. mozilla::LayoutFrameType type = aFrame->Type(); if (type == mozilla::LayoutFrameType::Table || diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp index e5223a50a0df..9477dbf9af15 100644 --- a/layout/generic/nsFrameSelection.cpp +++ b/layout/generic/nsFrameSelection.cpp @@ -1613,7 +1613,7 @@ nsIFrame* nsFrameSelection::GetFrameToPageSelect() const { continue; } ScrollStyles scrollStyles = scrollableFrame->GetScrollStyles(); - if (scrollStyles.mVertical == NS_STYLE_OVERFLOW_HIDDEN) { + if (scrollStyles.mVertical == StyleOverflow::Hidden) { continue; } uint32_t directions = scrollableFrame->GetPerceivedScrollingDirections(); diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 79e4a752ae24..e4fb8e10b901 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -189,14 +189,14 @@ enum class ShowScrollbar : uint8_t { Never, }; -static ShowScrollbar ShouldShowScrollbar(uint8_t aOverflow) { +static ShowScrollbar ShouldShowScrollbar(StyleOverflow aOverflow) { switch (aOverflow) { - case NS_STYLE_OVERFLOW_SCROLL: + case StyleOverflow::Scroll: return ShowScrollbar::Always; - case NS_STYLE_OVERFLOW_HIDDEN: + case StyleOverflow::Hidden: return ShowScrollbar::Never; default: - case NS_STYLE_OVERFLOW_AUTO: + case StyleOverflow::Auto: return ShowScrollbar::Auto; } } @@ -432,7 +432,7 @@ bool nsHTMLScrollFrame::TryLayout(ScrollReflowInput* aState, // care about what the page itself specifies. nsPresContext* pc = PresContext(); ScrollStyles styles = pc->GetViewportScrollStylesOverride(); - if (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) { + if (styles.mHorizontal != StyleOverflow::Hidden) { break; } // Only top level content document is considered. @@ -798,7 +798,7 @@ void nsHTMLScrollFrame::PlaceScrollArea(ScrollReflowInput& aState, nscoord nsHTMLScrollFrame::GetIntrinsicVScrollbarWidth( gfxContext* aRenderingContext) { ScrollStyles ss = GetScrollStyles(); - if (ss.mVertical != NS_STYLE_OVERFLOW_SCROLL || !mHelper.mVScrollbarBox) + if (ss.mVertical != StyleOverflow::Scroll || !mHelper.mVScrollbarBox) return 0; // Don't need to worry about reflow depth here since it's @@ -1310,9 +1310,9 @@ bool ScrollFrameHelper::WantAsyncScroll() const { } bool isVScrollable = (scrollRange.height >= oneDevPixel) && - (styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN); + (styles.mVertical != StyleOverflow::Hidden); bool isHScrollable = (scrollRange.width >= oneDevPixel) && - (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN); + (styles.mHorizontal != StyleOverflow::Hidden); #if defined(MOZ_WIDGET_ANDROID) // Mobile platforms need focus to scroll text inputs. @@ -1516,14 +1516,13 @@ nsSize nsXULScrollFrame::GetXULPrefSize(nsBoxLayoutState& aState) { // scrolled frames don't have their own margins - if (mHelper.mVScrollbarBox && styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) { + if (mHelper.mVScrollbarBox && styles.mVertical == StyleOverflow::Scroll) { nsSize vSize = mHelper.mVScrollbarBox->GetXULPrefSize(aState); nsBox::AddMargin(mHelper.mVScrollbarBox, vSize); pref.width += vSize.width; } - if (mHelper.mHScrollbarBox && - styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) { + if (mHelper.mHScrollbarBox && styles.mHorizontal == StyleOverflow::Scroll) { nsSize hSize = mHelper.mHScrollbarBox->GetXULPrefSize(aState); nsBox::AddMargin(mHelper.mHScrollbarBox, hSize); pref.height += hSize.height; @@ -1540,15 +1539,14 @@ nsSize nsXULScrollFrame::GetXULMinSize(nsBoxLayoutState& aState) { ScrollStyles styles = GetScrollStyles(); - if (mHelper.mVScrollbarBox && styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) { + if (mHelper.mVScrollbarBox && styles.mVertical == StyleOverflow::Scroll) { nsSize vSize = mHelper.mVScrollbarBox->GetXULMinSize(aState); AddMargin(mHelper.mVScrollbarBox, vSize); min.width += vSize.width; if (min.height < vSize.height) min.height = vSize.height; } - if (mHelper.mHScrollbarBox && - styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) { + if (mHelper.mHScrollbarBox && styles.mHorizontal == StyleOverflow::Scroll) { nsSize hSize = mHelper.mHScrollbarBox->GetXULMinSize(aState); AddMargin(mHelper.mHScrollbarBox, hSize); min.height += hSize.height; @@ -2392,8 +2390,8 @@ bool ScrollFrameHelper::IsAlwaysActive() const { // If we're overflow:hidden, then start as inactive until // we get scrolled manually. ScrollStyles styles = GetScrollStylesFromFrame(); - return (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN && - styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN); + return (styles.mHorizontal != StyleOverflow::Hidden && + styles.mVertical != StyleOverflow::Hidden); } static void RemoveDisplayPortCallback(nsITimer* aTimer, void* aClosure) { @@ -3876,7 +3874,7 @@ bool ScrollFrameHelper::IsRectNearlyVisible(const nsRect& aRect) const { } static void HandleScrollPref(nsIScrollable* aScrollable, int32_t aOrientation, - uint8_t& aValue) { + StyleOverflow& aValue) { int32_t pref; aScrollable->GetDefaultScrollbarPreferences(aOrientation, &pref); switch (pref) { @@ -3884,10 +3882,10 @@ static void HandleScrollPref(nsIScrollable* aScrollable, int32_t aOrientation, // leave |aValue| untouched break; case nsIScrollable::Scrollbar_Never: - aValue = NS_STYLE_OVERFLOW_HIDDEN; + aValue = StyleOverflow::Hidden; break; case nsIScrollable::Scrollbar_Always: - aValue = NS_STYLE_OVERFLOW_SCROLL; + aValue = StyleOverflow::Scroll; break; } } @@ -3896,7 +3894,7 @@ ScrollStyles ScrollFrameHelper::GetScrollStylesFromFrame() const { nsPresContext* presContext = mOuter->PresContext(); if (!presContext->IsDynamic() && !(mIsRoot && presContext->HasPaginatedScrolling())) { - return ScrollStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN); + return ScrollStyles(StyleOverflow::Hidden, StyleOverflow::Hidden); } if (!mIsRoot) { @@ -4537,8 +4535,8 @@ nsresult ScrollFrameHelper::CreateAnonymousContent( canHaveVertical = false; } else { ScrollStyles styles = scrollable->GetScrollStyles(); - canHaveHorizontal = styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN; - canHaveVertical = styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN; + canHaveHorizontal = styles.mHorizontal != StyleOverflow::Hidden; + canHaveVertical = styles.mVertical != StyleOverflow::Hidden; } if (!canHaveHorizontal && !canHaveVertical && !isResizable) { // Nothing to do. @@ -5222,9 +5220,9 @@ nsresult nsXULScrollFrame::XULLayout(nsBoxLayoutState& aState) { ScrollStyles styles = GetScrollStyles(); // Look at our style do we always have vertical or horizontal scrollbars? - if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) + if (styles.mHorizontal == StyleOverflow::Scroll) mHelper.mHasHorizontalScrollbar = true; - if (styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) + if (styles.mVertical == StyleOverflow::Scroll) mHelper.mHasVerticalScrollbar = true; if (mHelper.mHasHorizontalScrollbar) @@ -5240,13 +5238,13 @@ nsresult nsXULScrollFrame::XULLayout(nsBoxLayoutState& aState) { bool needsLayout = false; // if we have 'auto' scrollbars look at the vertical case - if (styles.mVertical != NS_STYLE_OVERFLOW_SCROLL) { + if (styles.mVertical != StyleOverflow::Scroll) { // These are only good until the call to LayoutScrollArea. nsRect scrolledRect = mHelper.GetScrolledRect(); // There are two cases to consider if (scrolledRect.height <= mHelper.mScrollPort.height || - styles.mVertical != NS_STYLE_OVERFLOW_AUTO) { + styles.mVertical != StyleOverflow::Auto) { if (mHelper.mHasVerticalScrollbar) { // We left room for the vertical scrollbar, but it's not needed; // remove it. @@ -5272,14 +5270,14 @@ nsresult nsXULScrollFrame::XULLayout(nsBoxLayoutState& aState) { } // if scrollbars are auto look at the horizontal case - if (styles.mHorizontal != NS_STYLE_OVERFLOW_SCROLL) { + if (styles.mHorizontal != StyleOverflow::Scroll) { // These are only good until the call to LayoutScrollArea. nsRect scrolledRect = mHelper.GetScrolledRect(); // if the child is wider that the scroll area // and we don't have a scrollbar add one. if ((scrolledRect.width > mHelper.mScrollPort.width) && - styles.mHorizontal == NS_STYLE_OVERFLOW_AUTO) { + styles.mHorizontal == StyleOverflow::Auto) { if (!mHelper.mHasHorizontalScrollbar) { // no scrollbar? if (AddHorizontalScrollbar(aState, scrollbarBottom)) { @@ -5305,7 +5303,7 @@ nsresult nsXULScrollFrame::XULLayout(nsBoxLayoutState& aState) { // Refresh scrolledRect because we called LayoutScrollArea. scrolledRect = mHelper.GetScrolledRect(); - if (styles.mVertical == NS_STYLE_OVERFLOW_AUTO && + if (styles.mVertical == StyleOverflow::Auto && !mHelper.mHasVerticalScrollbar && scrolledRect.height > mHelper.mScrollPort.height) { if (AddVerticalScrollbar(aState, scrollbarRight)) { @@ -5558,12 +5556,12 @@ bool ScrollFrameHelper::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) { bool needReflow = false; nsPoint scrollPosition = GetScrollPosition(); if (overflowChange & nsIScrollableFrame::HORIZONTAL) { - if (ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN || scrollPosition.x) { + if (ss.mHorizontal != StyleOverflow::Hidden || scrollPosition.x) { needReflow = true; } } if (overflowChange & nsIScrollableFrame::VERTICAL) { - if (ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN || scrollPosition.y) { + if (ss.mVertical != StyleOverflow::Hidden || scrollPosition.y) { needReflow = true; } } @@ -6138,7 +6136,7 @@ void ScrollFrameHelper::RestoreState(PresState* aState) { if (mIsRoot) { nsIPresShell* presShell = mOuter->PresShell(); - presShell->SetResolutionAndScaleTo(aState->resolution(), + presShell->SetResolutionAndScaleTo(aState->resolution(), nsGkAtoms::restore); } } diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index 5d18635cb332..2cf3101416ab 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -613,7 +613,7 @@ struct nsGridContainerFrame::GridItemInfo { aContainerWM.IsOrthogonalTo(mFrame->GetWritingMode()) && minSize.GetUnit() == eStyleUnit_Enumerated); return isAuto && - mFrame->StyleDisplay()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE; + mFrame->StyleDisplay()->mOverflowX == StyleOverflow::Visible; } #ifdef DEBUG @@ -3597,7 +3597,7 @@ static nscoord MinSize(const GridItemInfo& aGridItem, : style.GetUnit(); if (unit == eStyleUnit_Enumerated || (unit == eStyleUnit_Auto && - child->StyleDisplay()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE)) { + child->StyleDisplay()->mOverflowX == StyleOverflow::Visible)) { // Now calculate the "content size" part and return whichever is smaller. MOZ_ASSERT(unit != eStyleUnit_Enumerated || sz == NS_UNCONSTRAINEDSIZE); sz = std::min( diff --git a/layout/generic/nsIScrollableFrame.h b/layout/generic/nsIScrollableFrame.h index 33361008c68a..2b331d96ec7d 100644 --- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -61,8 +61,8 @@ class nsIScrollableFrame : public nsIScrollbarMediator { virtual nsIFrame* GetScrolledFrame() const = 0; /** - * Get the styles (NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN, - * or NS_STYLE_OVERFLOW_AUTO) governing the horizontal and vertical + * Get the styles (StyleOverflow::Scroll, StyleOverflow::Hidden, + * or StyleOverflow::Auto) governing the horizontal and vertical * scrollbars for this frame. */ virtual mozilla::ScrollStyles GetScrollStyles() const = 0; diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 3ca85bc034ff..0943e5800339 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -409,6 +409,7 @@ cbindgen-types = [ { gecko = "StyleFloat", servo = "values::computed::Float" }, { gecko = "StyleOverscrollBehavior", servo = "values::computed::OverscrollBehavior" }, { gecko = "StyleTextAlign", servo = "values::computed::TextAlign" }, + { gecko = "StyleOverflow", servo = "values::computed::Overflow" }, ] mapped-generic-types = [ diff --git a/layout/style/ServoCSSPropList.mako.py b/layout/style/ServoCSSPropList.mako.py index b10f282cafd9..8e4341dfe211 100644 --- a/layout/style/ServoCSSPropList.mako.py +++ b/layout/style/ServoCSSPropList.mako.py @@ -128,6 +128,7 @@ SERIALIZED_PREDEFINED_TYPES = [ "OverflowClipBox", "ScrollSnapType", "Float", + "Overflow", ] def serialized_by_servo(prop): diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index 23275f34f72b..11e818c1b3db 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -48,7 +48,6 @@ CSS_KEY(-moz-grid-group, _moz_grid_group) CSS_KEY(-moz-grid-line, _moz_grid_line) CSS_KEY(-moz-grid, _moz_grid) CSS_KEY(-moz-groupbox, _moz_groupbox) -CSS_KEY(-moz-hidden-unscrollable, _moz_hidden_unscrollable) CSS_KEY(-moz-inline-box, _moz_inline_box) CSS_KEY(-moz-inline-grid, _moz_inline_grid) CSS_KEY(-moz-inline-stack, _moz_inline_stack) @@ -116,7 +115,6 @@ CSS_KEY(grabbing, grabbing) CSS_KEY(grayscale, grayscale) CSS_KEY(grid, grid) CSS_KEY(help, help) -CSS_KEY(hidden, hidden) CSS_KEY(hue-rotate, hue_rotate) CSS_KEY(infinite, infinite) CSS_KEY(inline, inline) @@ -184,7 +182,6 @@ CSS_KEY(scale3d, scale3d) CSS_KEY(scalex, scalex) CSS_KEY(scaley, scaley) CSS_KEY(scalez, scalez) -CSS_KEY(scroll, scroll) CSS_KEY(se-resize, se_resize) CSS_KEY(self-end, self_end) CSS_KEY(self-start, self_start) @@ -230,7 +227,6 @@ CSS_KEY(under, under) CSS_KEY(underline, underline) CSS_KEY(unsafe, unsafe) CSS_KEY(vertical-text, vertical_text) -CSS_KEY(visible, visible) CSS_KEY(w-resize, w_resize) CSS_KEY(wait, wait) CSS_KEY(wavy, wavy) diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index efeaaf34416e..8e47f102f234 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -447,15 +447,6 @@ const KTableEntry nsCSSProps::kContainKTable[] = { {eCSSKeyword_size, NS_STYLE_CONTAIN_SIZE}, {eCSSKeyword_UNKNOWN, -1}}; -const KTableEntry nsCSSProps::kOverflowSubKTable[] = { - {eCSSKeyword_auto, NS_STYLE_OVERFLOW_AUTO}, - {eCSSKeyword_visible, NS_STYLE_OVERFLOW_VISIBLE}, - {eCSSKeyword_hidden, NS_STYLE_OVERFLOW_HIDDEN}, - {eCSSKeyword_scroll, NS_STYLE_OVERFLOW_SCROLL}, - // Deprecated: - {eCSSKeyword__moz_hidden_unscrollable, NS_STYLE_OVERFLOW_CLIP}, - {eCSSKeyword_UNKNOWN, -1}}; - const KTableEntry nsCSSProps::kTextAlignKTable[] = { {eCSSKeyword_left, NS_STYLE_TEXT_ALIGN_LEFT}, {eCSSKeyword_right, NS_STYLE_TEXT_ALIGN_RIGHT}, diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index 34eaf36e7883..383c360ffe7d 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -316,7 +316,6 @@ class nsCSSProps { static const KTableEntry kGridTrackBreadthKTable[]; static const KTableEntry kLineHeightKTable[]; static const KTableEntry kContainKTable[]; - static const KTableEntry kOverflowSubKTable[]; static const KTableEntry kTextAlignKTable[]; static const KTableEntry kTextDecorationLineKTable[]; static const KTableEntry kTextDecorationStyleKTable[]; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 7b106f2d4d05..6f90b2bff40c 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -2515,13 +2515,6 @@ already_AddRefed nsComputedDOMStyle::DoGetWillChange() { return valueList.forget(); } -already_AddRefed nsComputedDOMStyle::DoGetOverflowY() { - RefPtr val = new nsROCSSPrimitiveValue; - val->SetIdent(nsCSSProps::ValueToKeywordEnum(StyleDisplay()->mOverflowY, - nsCSSProps::kOverflowSubKTable)); - return val.forget(); -} - already_AddRefed nsComputedDOMStyle::DoGetTouchAction() { RefPtr val = new nsROCSSPrimitiveValue; diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 743ceb8594cf..198624e827a7 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -557,15 +557,6 @@ enum class StyleGridTrackBreadth : uint8_t { #define NS_STYLE_FRAME_SCROLL 7 #define NS_STYLE_FRAME_NOSCROLL 8 -// See nsStyleDisplay.mOverflow{X,Y} -#define NS_STYLE_OVERFLOW_VISIBLE 0 -#define NS_STYLE_OVERFLOW_HIDDEN 1 -#define NS_STYLE_OVERFLOW_SCROLL 2 -#define NS_STYLE_OVERFLOW_AUTO 3 -#define NS_STYLE_OVERFLOW_CLIP 4 -#define NS_STYLE_OVERFLOW_SCROLLBARS_HORIZONTAL 5 -#define NS_STYLE_OVERFLOW_SCROLLBARS_VERTICAL 6 - // See nsStyleList #define NS_STYLE_LIST_STYLE_CUSTOM -1 // for @counter-style #define NS_STYLE_LIST_STYLE_NONE 0 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 46baba45af90..61a456ea2a29 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -2977,8 +2977,8 @@ nsStyleDisplay::nsStyleDisplay(const nsPresContext* aContext) mBreakInside(StyleBreakWithin::Auto), mBreakBefore(StyleBreakBetween::Auto), mBreakAfter(StyleBreakBetween::Auto), - mOverflowX(NS_STYLE_OVERFLOW_VISIBLE), - mOverflowY(NS_STYLE_OVERFLOW_VISIBLE), + mOverflowX(StyleOverflow::Visible), + mOverflowY(StyleOverflow::Visible), mOverflowClipBoxBlock(StyleOverflowClipBox::PaddingBox), mOverflowClipBoxInline(StyleOverflowClipBox::PaddingBox), mResize(StyleResize::None), diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index f616b6f7bfdb..3d2c65369537 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1902,8 +1902,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay { mozilla::StyleBreakWithin mBreakInside; mozilla::StyleBreakBetween mBreakBefore; mozilla::StyleBreakBetween mBreakAfter; - uint8_t mOverflowX; // NS_STYLE_OVERFLOW_* - uint8_t mOverflowY; // NS_STYLE_OVERFLOW_* + mozilla::StyleOverflow mOverflowX; + mozilla::StyleOverflow mOverflowY; mozilla::StyleOverflowClipBox mOverflowClipBoxBlock; mozilla::StyleOverflowClipBox mOverflowClipBoxInline; mozilla::StyleResize mResize; @@ -2137,9 +2137,9 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay { bool IsScrollableOverflow() const { // mOverflowX and mOverflowY always match when one of them is - // NS_STYLE_OVERFLOW_VISIBLE or NS_STYLE_OVERFLOW_CLIP. - return mOverflowX != NS_STYLE_OVERFLOW_VISIBLE && - mOverflowX != NS_STYLE_OVERFLOW_CLIP; + // Visible or MozHiddenUnscrollable. + return mOverflowX != mozilla::StyleOverflow::Visible && + mOverflowX != mozilla::StyleOverflow::MozHiddenUnscrollable; } bool IsContainPaint() const { diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp index dd0eea9f7e12..ff06d754ad51 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/nsSVGUtils.cpp @@ -926,8 +926,8 @@ gfxRect nsSVGUtils::GetClipRectForFrame(nsIFrame* aFrame, float aX, float aY, return gfxRect(aX, aY, aWidth, aHeight); } - if (disp->mOverflowX == NS_STYLE_OVERFLOW_HIDDEN || - disp->mOverflowY == NS_STYLE_OVERFLOW_HIDDEN) { + if (disp->mOverflowX == StyleOverflow::Hidden || + disp->mOverflowY == StyleOverflow::Hidden) { nsIntRect clipPxRect = effects->mClip.ToOutsidePixels( aFrame->PresContext()->AppUnitsPerDevPixel()); gfxRect clipRect = gfxRect(clipPxRect.x, clipPxRect.y, clipPxRect.width, @@ -940,11 +940,11 @@ gfxRect nsSVGUtils::GetClipRectForFrame(nsIFrame* aFrame, float aX, float aY, clipRect.height = aHeight - clipRect.Y(); } - if (disp->mOverflowX != NS_STYLE_OVERFLOW_HIDDEN) { + if (disp->mOverflowX != StyleOverflow::Hidden) { clipRect.x = aX; clipRect.width = aWidth; } - if (disp->mOverflowY != NS_STYLE_OVERFLOW_HIDDEN) { + if (disp->mOverflowY != StyleOverflow::Hidden) { clipRect.y = aY; clipRect.height = aHeight; } diff --git a/layout/xul/nsBox.cpp b/layout/xul/nsBox.cpp index 7c44da48d2d8..ae834de91d85 100644 --- a/layout/xul/nsBox.cpp +++ b/layout/xul/nsBox.cpp @@ -305,10 +305,11 @@ nsresult nsIFrame::XULLayout(nsBoxLayoutState& aState) { bool nsBox::DoesClipChildren() { const nsStyleDisplay* display = StyleDisplay(); - NS_ASSERTION((display->mOverflowY == NS_STYLE_OVERFLOW_CLIP) == - (display->mOverflowX == NS_STYLE_OVERFLOW_CLIP), - "If one overflow is clip, the other should be too"); - return display->mOverflowX == NS_STYLE_OVERFLOW_CLIP; + NS_ASSERTION( + (display->mOverflowY == StyleOverflow::MozHiddenUnscrollable) == + (display->mOverflowX == StyleOverflow::MozHiddenUnscrollable), + "If one overflow is -moz-hidden-unscrollable, the other should be too"); + return display->mOverflowX == StyleOverflow::MozHiddenUnscrollable; } nsresult nsBox::SyncLayout(nsBoxLayoutState& aState) { diff --git a/servo/components/style/cbindgen.toml b/servo/components/style/cbindgen.toml index 3b5d56f98826..6005126fb276 100644 --- a/servo/components/style/cbindgen.toml +++ b/servo/components/style/cbindgen.toml @@ -64,5 +64,6 @@ include = [ "ScrollSnapType", "OverflowClipBox", "Resize", + "Overflow", ] item_types = ["enums", "structs", "typedefs"] diff --git a/servo/components/style/properties/data.py b/servo/components/style/properties/data.py index 52d8cf8ec036..8faaa1638230 100644 --- a/servo/components/style/properties/data.py +++ b/servo/components/style/properties/data.py @@ -325,6 +325,7 @@ class Longhand(object): "NonNegativeNumber", "Opacity", "OutlineStyle", + "Overflow", "OverflowClipBox", "OverflowWrap", "OverscrollBehavior", diff --git a/servo/components/style/properties/gecko.mako.rs b/servo/components/style/properties/gecko.mako.rs index 6381bc1f47e2..5f96b42c10a8 100644 --- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -1394,6 +1394,7 @@ impl Clone for ${style_struct.gecko_struct_name} { "OverflowClipBox": impl_simple, "ScrollSnapType": impl_simple, "Float": impl_simple, + "Overflow": impl_simple, "BreakBetween": impl_simple, "BreakWithin": impl_simple, "Resize": impl_simple, @@ -3011,7 +3012,7 @@ fn static_assert() { } -<% skip_box_longhands= """display overflow-y vertical-align +<% skip_box_longhands= """display vertical-align animation-name animation-delay animation-duration animation-direction animation-fill-mode animation-play-state animation-iteration-count animation-timing-function @@ -3063,28 +3064,6 @@ fn static_assert() { ) %> ${impl_keyword('clear', 'mBreakType', clear_keyword)} - <% overflow_x = data.longhands_by_name["overflow-x"] %> - pub fn set_overflow_y(&mut self, v: longhands::overflow_y::computed_value::T) { - use crate::properties::longhands::overflow_x::computed_value::T as BaseType; - // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts - self.gecko.mOverflowY = match v { - % for value in overflow_x.keyword.values_for('gecko'): - BaseType::${to_camel_case(value)} => structs::${overflow_x.keyword.gecko_constant(value)} as u8, - % endfor - }; - } - ${impl_simple_copy('overflow_y', 'mOverflowY')} - pub fn clone_overflow_y(&self) -> longhands::overflow_y::computed_value::T { - use crate::properties::longhands::overflow_x::computed_value::T as BaseType; - // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts - match self.gecko.mOverflowY as u32 { - % for value in overflow_x.keyword.values_for('gecko'): - structs::${overflow_x.keyword.gecko_constant(value)} => BaseType::${to_camel_case(value)}, - % endfor - x => panic!("Found unexpected value in style struct for overflow_y property: {}", x), - } - } - pub fn set_vertical_align(&mut self, v: longhands::vertical_align::computed_value::T) { use crate::values::generics::box_::VerticalAlign; let value = match v { diff --git a/servo/components/style/properties/longhands/box.mako.rs b/servo/components/style/properties/longhands/box.mako.rs index f0bf6b0bcdb7..1e0629861e45 100644 --- a/servo/components/style/properties/longhands/box.mako.rs +++ b/servo/components/style/properties/longhands/box.mako.rs @@ -100,34 +100,30 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box", )} % endfor -<% - overflow_custom_consts = { "-moz-hidden-unscrollable": "CLIP" } -%> - // FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`. // // We allow it to apply to placeholders for UA sheets, which set it !important. -${helpers.single_keyword( +${helpers.predefined_type( "overflow-x", - "visible hidden scroll auto", + "Overflow", + "computed::Overflow::Visible", animation_value_type="discrete", - extra_gecko_values="-moz-hidden-unscrollable", - custom_consts=overflow_custom_consts, - gecko_constant_prefix="NS_STYLE_OVERFLOW", flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-x", + needs_context=False, servo_restyle_damage = "reflow", )} -// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`. -// -// We allow it to apply to placeholders for UA sheets, which set it !important. -<%helpers:longhand name="overflow-y" animation_value_type="discrete" - flags="APPLIES_TO_PLACEHOLDER", - spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y" - servo_restyle_damage = "reflow"> - pub use super::overflow_x::{SpecifiedValue, parse, get_initial_value, computed_value}; - +${helpers.predefined_type( + "overflow-y", + "Overflow", + "computed::Overflow::Visible", + animation_value_type="discrete", + flags="APPLIES_TO_PLACEHOLDER", + spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y", + needs_context=False, + servo_restyle_damage = "reflow", +)} <% transition_extra_prefixes = "moz:layout.css.prefixes.transitions webkit" %> diff --git a/servo/components/style/values/computed/box.rs b/servo/components/style/values/computed/box.rs index 9ba38f040155..32ac16fb5749 100644 --- a/servo/components/style/values/computed/box.rs +++ b/servo/components/style/values/computed/box.rs @@ -13,7 +13,7 @@ use crate::values::specified::box_ as specified; pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin}; pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat}; -pub use crate::values::specified::box_::{Contain, Display, OverflowClipBox}; +pub use crate::values::specified::box_::{Contain, Display, Overflow, OverflowClipBox}; pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapType}; pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange}; diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs index d05d42e01022..8e135b52caa4 100644 --- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -43,7 +43,7 @@ pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderImageSlice, BorderImageWidth}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain}; pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float}; -pub use self::box_::{Display, TransitionProperty}; +pub use self::box_::{Display, TransitionProperty, Overflow}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize}; pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange}; pub use self::color::{Color, ColorPropertyValue, RGBAColor}; diff --git a/servo/components/style/values/specified/box.rs b/servo/components/style/values/specified/box.rs index 84cbe9e879c2..54030ba71395 100644 --- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -1363,3 +1363,28 @@ pub enum BreakWithin { Auto, Avoid, } + +/// The value for the `overflow-x` / `overflow-y` properties. +#[allow(missing_docs)] +#[derive( + Clone, + Copy, + Debug, + Eq, + Hash, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToCss, + ToComputedValue, +)] +#[repr(u8)] +pub enum Overflow { + Visible, + Hidden, + Scroll, + Auto, + #[cfg(feature = "gecko")] + MozHiddenUnscrollable, +} diff --git a/servo/components/style/values/specified/mod.rs b/servo/components/style/values/specified/mod.rs index c185dce80d05..3b8278c3287e 100644 --- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -36,7 +36,7 @@ pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display}; -pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float}; +pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float, Overflow}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize}; pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange}; pub use self::color::{Color, ColorPropertyValue, RGBAColor};