Bug 1479995 - Rename ScrollbarStyles to ScrollStyles. r=mstange

This change also renames several related functions, as well as fields,
and the header is moved into EXPORTS.mozilla given it is defined under
mozilla namespace.

MozReview-Commit-ID: LqCdcW8fmUN

--HG--
rename : layout/base/ScrollbarStyles.cpp => layout/base/ScrollStyles.cpp
rename : layout/base/ScrollbarStyles.h => layout/base/ScrollStyles.h
extra : rebase_source : 8933f3bca88d5db4b9508e3947f695ecf7511b3e
This commit is contained in:
Xidorn Quan 2018-08-01 16:14:26 +10:00
parent c3ae952e6e
commit 8421040c69
24 changed files with 121 additions and 121 deletions

View File

@ -6019,7 +6019,7 @@ nsDocShell::SetCurScrollPosEx(int32_t aCurHorizontalPos,
NS_ENSURE_TRUE(sf, NS_ERROR_FAILURE);
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;
if (sf->GetScrollbarStyles().mScrollBehavior ==
if (sf->GetScrollStyles().mScrollBehavior ==
NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
}

View File

@ -1346,7 +1346,7 @@ KeyframeEffect::CanThrottleOverflowChangesInScrollable(nsIFrame& aFrame) const
return true;
}
ScrollbarStyles ss = scrollable->GetScrollbarStyles();
ScrollStyles ss = scrollable->GetScrollStyles();
if (ss.mVertical == NS_STYLE_OVERFLOW_HIDDEN &&
ss.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
scrollable->GetLogicalScrollPosition() == nsPoint(0, 0)) {

View File

@ -805,7 +805,7 @@ Element::Scroll(const CSSIntPoint& aScroll, const ScrollOptions& aOptions)
if (aOptions.mBehavior == ScrollBehavior::Smooth) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
} else if (aOptions.mBehavior == ScrollBehavior::Auto) {
ScrollbarStyles styles = sf->GetScrollbarStyles();
ScrollStyles styles = sf->GetScrollStyles();
if (styles.mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
}
@ -902,7 +902,7 @@ Element::SetScrollTop(int32_t aScrollTop)
nsIScrollableFrame* sf = GetScrollFrame(nullptr, flushType);
if (sf) {
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;
if (sf->GetScrollbarStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
if (sf->GetScrollStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
}
sf->ScrollToCSSPixels(CSSIntPoint(sf->GetScrollPositionCSSPixels().x,
@ -927,7 +927,7 @@ Element::SetScrollLeft(int32_t aScrollLeft)
nsIScrollableFrame* sf = GetScrollFrame();
if (sf) {
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;
if (sf->GetScrollbarStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
if (sf->GetScrollStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) {
scrollMode = nsIScrollableFrame::SMOOTH_MSD;
}
@ -1970,7 +1970,7 @@ Element::UnbindFromTree(bool aDeep, bool aNullParent)
nsPresContext* presContext = document->GetPresContext();
if (presContext) {
MOZ_ASSERT(this !=
presContext->GetViewportScrollbarStylesOverrideElement(),
presContext->GetViewportScrollStylesOverrideElement(),
"Leaving behind a raw pointer to this element (as having "
"propagated scrollbar styles) - that's dangerous...");
}

View File

@ -7291,7 +7291,7 @@ nsIDocument::UpdateViewportOverflowType(nscoord aScrolledWidth,
#ifdef DEBUG
MOZ_ASSERT(mPresShell);
nsPresContext* pc = GetPresContext();
MOZ_ASSERT(pc->GetViewportScrollbarStylesOverride().mHorizontal ==
MOZ_ASSERT(pc->GetViewportScrollStylesOverride().mHorizontal ==
NS_STYLE_OVERFLOW_HIDDEN,
"Should only be called when viewport has overflow-x: hidden");
MOZ_ASSERT(aScrolledWidth > aScrollportWidth,
@ -10696,7 +10696,7 @@ static void
UpdateViewportScrollbarOverrideForFullscreen(nsIDocument* aDoc)
{
if (nsPresContext* presContext = aDoc->GetPresContext()) {
presContext->UpdateViewportScrollbarStylesOverride();
presContext->UpdateViewportScrollStylesOverride();
}
}

View File

@ -3924,7 +3924,7 @@ nsGlobalWindowInner::ScrollTo(const CSSIntPoint& aScroll,
scroll.y = maxpx;
}
bool smoothScroll = sf->GetScrollbarStyles().IsSmoothScroll(aOptions.mBehavior);
bool smoothScroll = sf->GetScrollStyles().IsSmoothScroll(aOptions.mBehavior);
sf->ScrollToCSSPixels(scroll, smoothScroll
? nsIScrollableFrame::SMOOTH_MSD
@ -3978,7 +3978,7 @@ nsGlobalWindowInner::ScrollByLines(int32_t numLines,
// It seems like it would make more sense for ScrollByLines to use
// SMOOTH mode, but tests seem to depend on the synchronous behaviour.
// Perhaps Web content does too.
bool smoothScroll = sf->GetScrollbarStyles().IsSmoothScroll(aOptions.mBehavior);
bool smoothScroll = sf->GetScrollStyles().IsSmoothScroll(aOptions.mBehavior);
sf->ScrollBy(nsIntPoint(0, numLines), nsIScrollableFrame::LINES,
smoothScroll
@ -3997,7 +3997,7 @@ nsGlobalWindowInner::ScrollByPages(int32_t numPages,
// It seems like it would make more sense for ScrollByPages to use
// SMOOTH mode, but tests seem to depend on the synchronous behaviour.
// Perhaps Web content does too.
bool smoothScroll = sf->GetScrollbarStyles().IsSmoothScroll(aOptions.mBehavior);
bool smoothScroll = sf->GetScrollStyles().IsSmoothScroll(aOptions.mBehavior);
sf->ScrollBy(nsIntPoint(0, numPages), nsIScrollableFrame::PAGES,
smoothScroll

View File

@ -2683,7 +2683,7 @@ EventStateManager::ComputeScrollTargetAndMayAdjustWheelEvent(
}
}
ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
ScrollStyles ss = scrollableFrame->GetScrollStyles();
bool hiddenForV = (NS_STYLE_OVERFLOW_HIDDEN == ss.mVertical);
bool hiddenForH = (NS_STYLE_OVERFLOW_HIDDEN == ss.mHorizontal);
if ((hiddenForV && hiddenForH) ||
@ -2796,7 +2796,7 @@ EventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
ComputeScrollAmountForDefaultAction(aEvent, scrollAmountInDevPixels);
// Don't scroll around the axis whose overflow style is hidden.
ScrollbarStyles overflowStyle = aScrollableFrame->GetScrollbarStyles();
ScrollStyles overflowStyle = aScrollableFrame->GetScrollStyles();
if (overflowStyle.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
actualDevPixelScrollAmount.x = 0;
}

View File

@ -127,13 +127,13 @@ ScrollFrameTo(nsIScrollableFrame* aFrame, const FrameMetrics& aMetrics, bool& aS
// 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->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_HIDDEN &&
if (aFrame->GetScrollStyles().mVertical == NS_STYLE_OVERFLOW_HIDDEN &&
targetScrollPosition.y != geckoScrollPosition.y) {
NS_WARNING(nsPrintfCString(
"APZCCH: targetScrollPosition.y (%f) != geckoScrollPosition.y (%f)",
targetScrollPosition.y, geckoScrollPosition.y).get());
}
if (aFrame->GetScrollbarStyles().mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
if (aFrame->GetScrollStyles().mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
targetScrollPosition.x != geckoScrollPosition.x) {
NS_WARNING(nsPrintfCString(
"APZCCH: targetScrollPosition.x (%f) != geckoScrollPosition.x (%f)",

View File

@ -3457,7 +3457,7 @@ static void ScrollToShowRect(nsIScrollableFrame* aFrameAsScrollable,
aHorizontal.mWhenToScroll == nsIPresShell::SCROLL_IF_NOT_VISIBLE) {
lineSize = aFrameAsScrollable->GetLineScrollAmount();
}
ScrollbarStyles ss = aFrameAsScrollable->GetScrollbarStyles();
ScrollStyles ss = aFrameAsScrollable->GetScrollStyles();
nsRect allowedRange(scrollPt, nsSize(0, 0));
bool needToScroll = false;
uint32_t directions = aFrameAsScrollable->GetPerceivedScrollingDirections();
@ -3514,7 +3514,7 @@ static void ScrollToShowRect(nsIScrollableFrame* aFrameAsScrollable,
// a current smooth scroll operation.
if (needToScroll) {
nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT;
bool autoBehaviorIsSmooth = (aFrameAsScrollable->GetScrollbarStyles().mScrollBehavior
bool autoBehaviorIsSmooth = (aFrameAsScrollable->GetScrollStyles().mScrollBehavior
== NS_STYLE_SCROLL_BEHAVIOR_SMOOTH);
bool smoothScroll = (aFlags & nsIPresShell::SCROLL_SMOOTH) ||
((aFlags & nsIPresShell::SCROLL_SMOOTH_AUTO) && autoBehaviorIsSmooth);

View File

@ -1381,9 +1381,9 @@ RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
// to reconstruct - we can just reflow, because no scrollframe is being
// added/removed.
nsIContent* prevOverrideNode =
presContext->GetViewportScrollbarStylesOverrideElement();
presContext->GetViewportScrollStylesOverrideElement();
nsIContent* newOverrideNode =
presContext->UpdateViewportScrollbarStylesOverride();
presContext->UpdateViewportScrollStylesOverride();
if (data.mContent == prevOverrideNode ||
data.mContent == newOverrideNode) {

View File

@ -4,13 +4,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ScrollbarStyles.h"
#include "mozilla/ScrollStyles.h"
#include "nsStyleStruct.h" // for nsStyleDisplay and nsStyleBackground::Position
namespace mozilla {
ScrollbarStyles::ScrollbarStyles(uint8_t aH, uint8_t aV,
const nsStyleDisplay* aDisplay)
ScrollStyles::ScrollStyles(uint8_t aH, uint8_t aV,
const nsStyleDisplay* aDisplay)
: mHorizontal(aH), mVertical(aV),
mScrollBehavior(aDisplay->mScrollBehavior),
mOverscrollBehaviorX(aDisplay->mOverscrollBehaviorX),
@ -22,7 +22,7 @@ namespace mozilla {
mScrollSnapDestinationX(aDisplay->mScrollSnapDestination.mXPosition),
mScrollSnapDestinationY(aDisplay->mScrollSnapDestination.mYPosition) {}
ScrollbarStyles::ScrollbarStyles(const nsStyleDisplay* aDisplay)
ScrollStyles::ScrollStyles(const nsStyleDisplay* aDisplay)
: mHorizontal(aDisplay->mOverflowX), mVertical(aDisplay->mOverflowY),
mScrollBehavior(aDisplay->mScrollBehavior),
mOverscrollBehaviorX(aDisplay->mOverscrollBehaviorX),

View File

@ -4,8 +4,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef ScrollbarStyles_h
#define ScrollbarStyles_h
#ifndef mozilla_ScrollStyles_h
#define mozilla_ScrollStyles_h
#include <stdint.h>
#include "nsStyleConsts.h" // for NS_STYLE_SCROLL_SNAP_*
@ -17,7 +17,7 @@ struct nsStyleDisplay;
namespace mozilla {
struct ScrollbarStyles
struct ScrollStyles
{
// Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
// or NS_STYLE_OVERFLOW_AUTO.
@ -37,7 +37,7 @@ struct ScrollbarStyles
nsStyleCoord::CalcValue mScrollSnapDestinationX;
nsStyleCoord::CalcValue mScrollSnapDestinationY;
ScrollbarStyles(uint8_t aH, uint8_t aV)
ScrollStyles(uint8_t aH, uint8_t aV)
: mHorizontal(aH), mVertical(aV),
mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO),
mOverscrollBehaviorX(StyleOverscrollBehavior::Auto),
@ -55,9 +55,9 @@ struct ScrollbarStyles
mScrollSnapDestinationY.mHasPercent = false;
}
explicit ScrollbarStyles(const nsStyleDisplay* aDisplay);
ScrollbarStyles(uint8_t aH, uint8_t aV, const nsStyleDisplay* aDisplay);
bool operator==(const ScrollbarStyles& aStyles) const {
explicit ScrollStyles(const nsStyleDisplay* aDisplay);
ScrollStyles(uint8_t aH, uint8_t aV, const nsStyleDisplay* aDisplay);
bool operator==(const ScrollStyles& aStyles) const {
return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical &&
aStyles.mScrollBehavior == mScrollBehavior &&
aStyles.mOverscrollBehaviorX == mOverscrollBehaviorX &&
@ -69,7 +69,7 @@ struct ScrollbarStyles
aStyles.mScrollSnapDestinationX == mScrollSnapDestinationX &&
aStyles.mScrollSnapDestinationY == mScrollSnapDestinationY;
}
bool operator!=(const ScrollbarStyles& aStyles) const {
bool operator!=(const ScrollStyles& aStyles) const {
return !(*this == aStyles);
}
bool IsHiddenInBothDirections() const {
@ -85,4 +85,4 @@ struct ScrollbarStyles
} // namespace mozilla
#endif
#endif // mozilla_ScrollStyles_h

View File

@ -63,7 +63,6 @@ EXPORTS += [
'nsRefreshDriver.h',
'nsStyleChangeList.h',
'nsStyleSheetService.h',
'ScrollbarStyles.h',
'StackArena.h',
'TouchManager.h',
'Units.h',
@ -80,6 +79,7 @@ EXPORTS.mozilla += [
'OverflowChangedTracker.h',
'PresShell.h',
'RestyleManager.h',
'ScrollStyles.h',
'ShapeUtils.h',
'StaticPresData.h',
'UndisplayedNode.h',
@ -113,7 +113,7 @@ UNIFIED_SOURCES += [
'PositionedEventTargeting.cpp',
'PresShell.cpp',
'RestyleManager.cpp',
'ScrollbarStyles.cpp',
'ScrollStyles.cpp',
'ShapeUtils.cpp',
'StackArena.cpp',
'StaticPresData.cpp',

View File

@ -2409,12 +2409,12 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle
GetRootFrame()->SetComputedStyleWithoutNotification(sc);
}
// Make sure to call UpdateViewportScrollbarStylesOverride before
// Make sure to call UpdateViewportScrollStylesOverride before
// SetUpDocElementContainingBlock, since it sets up our scrollbar state
// properly.
DebugOnly<nsIContent*> propagatedScrollFrom;
if (nsPresContext* presContext = mPresShell->GetPresContext()) {
propagatedScrollFrom = presContext->UpdateViewportScrollbarStylesOverride();
propagatedScrollFrom = presContext->UpdateViewportScrollStylesOverride();
}
SetUpDocElementContainingBlock(aDocElement);
@ -4529,7 +4529,7 @@ nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay& aDisplay,
if (aElement.IsHTMLElement(nsGkAtoms::body)) {
if (nsPresContext* presContext = mPresShell->GetPresContext()) {
propagatedScrollToViewport =
presContext->UpdateViewportScrollbarStylesOverride() == &aElement;
presContext->UpdateViewportScrollStylesOverride() == &aElement;
}
}
@ -4565,7 +4565,7 @@ nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay& aDisplay,
// scrollframe so that it paginates correctly, but we don't want to set
// the bit on the block that tells it to clip at paint time.
if (mPresShell->GetPresContext()->
ElementWouldPropagateScrollbarStyles(aElement)) {
ElementWouldPropagateScrollStyles(aElement)) {
suppressScrollFrame = false;
}
}
@ -7688,7 +7688,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aChild,
// <body> child of the root element. So we can only be removing the stored
// override element if the thing being removed is either the override element
// itself or the root element (which can be a parent of the override element).
if (aChild == presContext->GetViewportScrollbarStylesOverrideElement() ||
if (aChild == presContext->GetViewportScrollStylesOverrideElement() ||
(aChild->IsElement() && !aChild->GetParent())) {
// We might be removing the element that we propagated viewport scrollbar
// styles from. Recompute those. (This clause covers two of the three
@ -7700,7 +7700,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aChild,
// We don't handle the fullscreen case here, because it doesn't change the
// scrollbar styles override element stored on the prescontext.)
Element* newOverrideElement =
presContext->UpdateViewportScrollbarStylesOverride();
presContext->UpdateViewportScrollStylesOverride();
// If aChild is the root, then we don't need to do any reframing of
// newOverrideElement, because we're about to tear down the whole frame tree

View File

@ -16,6 +16,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/LinkedList.h"
#include "mozilla/RestyleManager.h"
#include "mozilla/ScrollStyles.h"
#include "nsCOMPtr.h"
#include "nsILayoutHistoryState.h"
@ -23,7 +24,6 @@
#include "nsCounterManager.h"
#include "nsIAnonymousContentCreator.h"
#include "nsFrameManager.h"
#include "ScrollbarStyles.h"
struct nsFrameItems;
struct nsStyleDisplay;

View File

@ -1965,7 +1965,7 @@ nsLayoutUtils::GetNearestScrollableFrameForDirection(nsIFrame* aFrame,
for (nsIFrame* f = aFrame; f; f = nsLayoutUtils::GetCrossDocParentFrame(f)) {
nsIScrollableFrame* scrollableFrame = do_QueryFrame(f);
if (scrollableFrame) {
ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
ScrollStyles ss = scrollableFrame->GetScrollStyles();
uint32_t directions = scrollableFrame->GetPerceivedScrollingDirections();
if (aDirection == eVertical ?
(ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN &&
@ -1992,7 +1992,7 @@ nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame, uint32_t aFlags)
return scrollableFrame;
}
} else {
ScrollbarStyles ss = scrollableFrame->GetScrollbarStyles();
ScrollStyles ss = scrollableFrame->GetScrollStyles();
if ((aFlags & SCROLLABLE_INCLUDE_HIDDEN) ||
ss.mVertical != NS_STYLE_OVERFLOW_HIDDEN ||
ss.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
@ -8730,11 +8730,11 @@ nsLayoutUtils::CalculateScrollableRectForFrame(nsIScrollableFrame* aScrollableFr
contentBounds = aScrollableFrame->GetScrollRange();
nsPoint scrollPosition = aScrollableFrame->GetScrollPosition();
if (aScrollableFrame->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_HIDDEN) {
if (aScrollableFrame->GetScrollStyles().mVertical == NS_STYLE_OVERFLOW_HIDDEN) {
contentBounds.y = scrollPosition.y;
contentBounds.height = 0;
}
if (aScrollableFrame->GetScrollbarStyles().mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
if (aScrollableFrame->GetScrollStyles().mHorizontal == NS_STYLE_OVERFLOW_HIDDEN) {
contentBounds.x = scrollPosition.x;
contentBounds.width = 0;
}
@ -9169,10 +9169,10 @@ nsLayoutUtils::ComputeScrollMetadata(nsIFrame* aForFrame,
metadata.SetSnapInfo(scrollableFrame->GetScrollSnapInfo());
ScrollbarStyles scrollbarStyles = scrollableFrame->GetScrollbarStyles();
ScrollStyles scrollStyles = scrollableFrame->GetScrollStyles();
metadata.SetOverscrollBehavior(OverscrollBehaviorInfo::FromStyleConstants(
scrollbarStyles.mOverscrollBehaviorX,
scrollbarStyles.mOverscrollBehaviorY));
scrollStyles.mOverscrollBehaviorX,
scrollStyles.mOverscrollBehaviorY));
}
// If we have the scrollparent being the same as the scroll id, the

View File

@ -197,8 +197,8 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
mFocusBackgroundColor(mBackgroundColor),
mFocusTextColor(mDefaultColor),
mBodyTextColor(mDefaultColor),
mViewportScrollbarOverrideElement(nullptr),
mViewportStyleScrollbar(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO),
mViewportScrollOverrideElement(nullptr),
mViewportScrollStyles(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO),
mFocusRingWidth(1),
mExistThrottledUpdates(false),
// mImageAnimationMode is initialised below, in constructor body
@ -1334,7 +1334,7 @@ nsPresContext::ScreenSizeInchesForFontInflation(bool* aChanged)
}
static bool
CheckOverflow(const nsStyleDisplay* aDisplay, ScrollbarStyles* aStyles)
CheckOverflow(const nsStyleDisplay* aDisplay, ScrollStyles* aStyles)
{
if (aDisplay->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE &&
aDisplay->mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_AUTO &&
@ -1350,17 +1350,17 @@ CheckOverflow(const nsStyleDisplay* aDisplay, ScrollbarStyles* aStyles)
}
if (aDisplay->mOverflowX == NS_STYLE_OVERFLOW_CLIP) {
*aStyles = ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN,
NS_STYLE_OVERFLOW_HIDDEN, aDisplay);
*aStyles = ScrollStyles(NS_STYLE_OVERFLOW_HIDDEN,
NS_STYLE_OVERFLOW_HIDDEN, aDisplay);
} else {
*aStyles = ScrollbarStyles(aDisplay);
*aStyles = ScrollStyles(aDisplay);
}
return true;
}
static Element*
GetPropagatedScrollbarStylesForViewport(nsPresContext* aPresContext,
ScrollbarStyles *aStyles)
GetPropagatedScrollStylesForViewport(nsPresContext* aPresContext,
ScrollStyles *aStyles)
{
nsIDocument* document = aPresContext->Document();
Element* docElement = document->GetRootElement();
@ -1410,16 +1410,16 @@ GetPropagatedScrollbarStylesForViewport(nsPresContext* aPresContext,
}
Element*
nsPresContext::UpdateViewportScrollbarStylesOverride()
nsPresContext::UpdateViewportScrollStylesOverride()
{
// Start off with our default styles, and then update them as needed.
mViewportStyleScrollbar = ScrollbarStyles(NS_STYLE_OVERFLOW_AUTO,
NS_STYLE_OVERFLOW_AUTO);
mViewportScrollbarOverrideElement = nullptr;
mViewportScrollStyles = ScrollStyles(NS_STYLE_OVERFLOW_AUTO,
NS_STYLE_OVERFLOW_AUTO);
mViewportScrollOverrideElement = nullptr;
// Don't propagate the scrollbar state in printing or print preview.
if (!IsPaginated()) {
mViewportScrollbarOverrideElement =
GetPropagatedScrollbarStylesForViewport(this, &mViewportStyleScrollbar);
mViewportScrollOverrideElement =
GetPropagatedScrollStylesForViewport(this, &mViewportScrollStyles);
}
nsIDocument* document = Document();
@ -1430,16 +1430,16 @@ nsPresContext::UpdateViewportScrollbarStylesOverride()
// the styles are from, so that the state of those elements is not
// affected across fullscreen change.
if (fullscreenElement != document->GetRootElement() &&
fullscreenElement != mViewportScrollbarOverrideElement) {
mViewportStyleScrollbar = ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN,
NS_STYLE_OVERFLOW_HIDDEN);
fullscreenElement != mViewportScrollOverrideElement) {
mViewportScrollStyles = ScrollStyles(NS_STYLE_OVERFLOW_HIDDEN,
NS_STYLE_OVERFLOW_HIDDEN);
}
}
return mViewportScrollbarOverrideElement;
return mViewportScrollOverrideElement;
}
bool
nsPresContext::ElementWouldPropagateScrollbarStyles(const Element& aElement)
nsPresContext::ElementWouldPropagateScrollStyles(const Element& aElement)
{
MOZ_ASSERT(IsPaginated(), "Should only be called on paginated contexts");
if (aElement.GetParent() && !aElement.IsHTMLElement(nsGkAtoms::body)) {
@ -1447,13 +1447,13 @@ nsPresContext::ElementWouldPropagateScrollbarStyles(const Element& aElement)
return false;
}
// Go ahead and just call GetPropagatedScrollbarStylesForViewport, but update
// a dummy ScrollbarStyles we don't care about. It'll do a bit of extra work,
// Go ahead and just call GetPropagatedScrollStylesForViewport, but update
// a dummy ScrollStyles we don't care about. It'll do a bit of extra work,
// 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.
ScrollbarStyles dummy(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO);
return GetPropagatedScrollbarStylesForViewport(this, &dummy) == &aElement;
ScrollStyles dummy(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO);
return GetPropagatedScrollStylesForViewport(this, &dummy) == &aElement;
}
void

View File

@ -12,6 +12,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/MediaFeatureChange.h"
#include "mozilla/NotNull.h"
#include "mozilla/ScrollStyles.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WeakPtr.h"
#include "nsColor.h"
@ -41,7 +42,6 @@
#include "mozilla/AppUnits.h"
#include "prclist.h"
#include "nsThreadUtils.h"
#include "ScrollbarStyles.h"
#include "nsIMessageManager.h"
#include "Units.h"
#include "prenv.h"
@ -133,7 +133,7 @@ public:
using Encoding = mozilla::Encoding;
template <typename T> using NotNull = mozilla::NotNull<T>;
typedef mozilla::LangGroupFontPrefs LangGroupFontPrefs;
typedef mozilla::ScrollbarStyles ScrollbarStyles;
typedef mozilla::ScrollStyles ScrollStyles;
typedef mozilla::StaticPresData StaticPresData;
using TransactionId = mozilla::layers::TransactionId;
@ -754,28 +754,28 @@ public:
* @return if scroll was propagated from some content node, the content node
* it was propagated from.
*/
mozilla::dom::Element* UpdateViewportScrollbarStylesOverride();
mozilla::dom::Element* UpdateViewportScrollStylesOverride();
/**
* Returns the cached result from the last call to
* UpdateViewportScrollbarStylesOverride() -- i.e. return the node
* UpdateViewportScrollStylesOverride() -- i.e. return the node
* whose scrollbar styles we have propagated to the viewport (or nullptr if
* there is no such node).
*/
mozilla::dom::Element* GetViewportScrollbarStylesOverrideElement() const {
return mViewportScrollbarOverrideElement;
mozilla::dom::Element* GetViewportScrollStylesOverrideElement() const {
return mViewportScrollOverrideElement;
}
const ScrollbarStyles& GetViewportScrollbarStylesOverride() const
const ScrollStyles& GetViewportScrollStylesOverride() const
{
return mViewportStyleScrollbar;
return mViewportScrollStyles;
}
/**
* Check whether the given element would propagate its scrollbar styles to the
* viewport in non-paginated mode. Must only be called if IsPaginated().
*/
bool ElementWouldPropagateScrollbarStyles(const mozilla::dom::Element&);
bool ElementWouldPropagateScrollStyles(const mozilla::dom::Element&);
/**
* Set and get methods for controlling the background drawing
@ -1353,13 +1353,13 @@ protected:
// This is a non-owning pointer. May be null. If non-null, it's guaranteed to
// be pointing to an element that's still alive, because we'll reset it in
// UpdateViewportScrollbarStylesOverride() as part of the cleanup code when
// UpdateViewportScrollStylesOverride() as part of the cleanup code when
// this element is removed from the document. (For <body> and the root
// element, this call happens in nsCSSFrameConstructor::ContentRemoved(). For
// fullscreen elements, it happens in the fullscreen-specific cleanup invoked
// by Element::UnbindFromTree().)
mozilla::dom::Element* MOZ_NON_OWNING_REF mViewportScrollbarOverrideElement;
ScrollbarStyles mViewportStyleScrollbar;
mozilla::dom::Element* MOZ_NON_OWNING_REF mViewportScrollOverrideElement;
ScrollStyles mViewportScrollStyles;
uint8_t mFocusRingWidth;

View File

@ -622,17 +622,17 @@ nsListControlFrame::ReflowAsDropdown(nsPresContext* aPresContext,
nsHTMLScrollFrame::Reflow(aPresContext, aDesiredSize, state, aStatus);
}
ScrollbarStyles
nsListControlFrame::GetScrollbarStyles() const
ScrollStyles
nsListControlFrame::GetScrollStyles() const
{
// We can't express this in the style system yet; when we can, this can go away
// and GetScrollbarStyles can be devirtualized
// and GetScrollStyles can be devirtualized
int32_t style = IsInDropDownMode() ? NS_STYLE_OVERFLOW_AUTO
: NS_STYLE_OVERFLOW_SCROLL;
if (GetWritingMode().IsVertical()) {
return ScrollbarStyles(style, NS_STYLE_OVERFLOW_HIDDEN);
return ScrollStyles(style, NS_STYLE_OVERFLOW_HIDDEN);
} else {
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, style);
return ScrollStyles(NS_STYLE_OVERFLOW_HIDDEN, style);
}
}

View File

@ -102,7 +102,7 @@ public:
virtual nsresult SetFormProperty(nsAtom* aName, const nsAString& aValue) override;
virtual void SetFocus(bool aOn = true, bool aRepaint = false) override;
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const override;
virtual mozilla::ScrollStyles GetScrollStyles() const override;
virtual bool ShouldPropagateComputedBSizeToScrolledContent() const override;
// for accessibility purposes

View File

@ -342,8 +342,8 @@ TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder,
mCanHaveInlineAxisScrollbar = false;
if (mScrollableFrame) {
auto scrollbarStyle = mBlockWM.IsVertical() ?
mScrollableFrame->GetScrollbarStyles().mVertical :
mScrollableFrame->GetScrollbarStyles().mHorizontal;
mScrollableFrame->GetScrollStyles().mVertical :
mScrollableFrame->GetScrollStyles().mHorizontal;
mCanHaveInlineAxisScrollbar = scrollbarStyle != NS_STYLE_OVERFLOW_HIDDEN;
if (!mAdjustForPixelSnapping) {
// Scrolling to the end position can leave some text still overflowing due

View File

@ -9993,7 +9993,7 @@ nsIFrame::IsFocusable(int32_t *aTabIndex, bool aWithMouse)
// will be enough to make them keyboard scrollable.
nsIScrollableFrame *scrollFrame = do_QueryFrame(this);
if (scrollFrame &&
!scrollFrame->GetScrollbarStyles().IsHiddenInBothDirections() &&
!scrollFrame->GetScrollStyles().IsHiddenInBothDirections() &&
!scrollFrame->GetScrollRange().IsEqualEdges(nsRect(0, 0, 0, 0))) {
// Scroll bars will be used for overflow
isFocusable = true;

View File

@ -216,7 +216,7 @@ namespace mozilla {
struct MOZ_STACK_CLASS ScrollReflowInput {
const ReflowInput& mReflowInput;
nsBoxLayoutState mBoxState;
ScrollbarStyles mStyles;
ScrollStyles mStyles;
nsMargin mComputedBorder;
// === Filled in by ReflowScrolledFrame ===
@ -242,7 +242,7 @@ struct MOZ_STACK_CLASS ScrollReflowInput {
// mBoxState is just used for scrollbars so we don't need to
// worry about the reflow depth here
mBoxState(aReflowInput.mFrame->PresContext(), aReflowInput.mRenderingContext, 0),
mStyles(aFrame->GetScrollbarStyles()) {
mStyles(aFrame->GetScrollStyles()) {
}
};
@ -439,7 +439,7 @@ nsHTMLScrollFrame::TryLayout(ScrollReflowInput* aState,
// because the latter can be affected by various factors, while we
// only care about what the page itself specifies.
nsPresContext* pc = PresContext();
ScrollbarStyles styles = pc->GetViewportScrollbarStylesOverride();
ScrollStyles styles = pc->GetViewportScrollStylesOverride();
if (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN) {
break;
}
@ -822,7 +822,7 @@ nsHTMLScrollFrame::PlaceScrollArea(ScrollReflowInput& aState,
nscoord
nsHTMLScrollFrame::GetIntrinsicVScrollbarWidth(gfxContext *aRenderingContext)
{
ScrollbarStyles ss = GetScrollbarStyles();
ScrollStyles ss = GetScrollStyles();
if (ss.mVertical != NS_STYLE_OVERFLOW_SCROLL || !mHelper.mVScrollbarBox)
return 0;
@ -1174,7 +1174,7 @@ nsHTMLScrollFrame::AccessibleType()
// Create an accessible regardless of focusable state because the state can be
// changed during frame life cycle without any notifications to accessibility.
if (mContent->IsRootOfNativeAnonymousSubtree() ||
GetScrollbarStyles().IsHiddenInBothDirections()) {
GetScrollStyles().IsHiddenInBothDirections()) {
return a11y::eNoType;
}
@ -1355,7 +1355,7 @@ ScrollFrameHelper::WantAsyncScroll() const
return true;
}
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
ScrollStyles styles = GetScrollStylesFromFrame();
nscoord oneDevPixel = GetScrolledFrame()->PresContext()->AppUnitsPerDevPixel();
nsRect scrollRange = GetScrollRange();
bool isVScrollable = (scrollRange.height >= oneDevPixel) &&
@ -1600,7 +1600,7 @@ nsXULScrollFrame::GetXULPrefSize(nsBoxLayoutState& aState)
{
nsSize pref = mHelper.mScrolledFrame->GetXULPrefSize(aState);
ScrollbarStyles styles = GetScrollbarStyles();
ScrollStyles styles = GetScrollStyles();
// scrolled frames don't have their own margins
@ -1629,7 +1629,7 @@ nsXULScrollFrame::GetXULMinSize(nsBoxLayoutState& aState)
{
nsSize min = mHelper.mScrolledFrame->GetXULMinSizeForScrollArea(aState);
ScrollbarStyles styles = GetScrollbarStyles();
ScrollStyles styles = GetScrollStyles();
if (mHelper.mVScrollbarBox &&
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
@ -2539,7 +2539,7 @@ bool ScrollFrameHelper::IsAlwaysActive() const
// If we're overflow:hidden, then start as inactive until
// we get scrolled manually.
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
ScrollStyles styles = GetScrollStylesFromFrame();
return (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN &&
styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN);
}
@ -3717,9 +3717,9 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// does not arrive within the timeout period). Otherwise, APZ's
// fallback behaviour of scrolling the enclosing scroll frame would
// violate the specified overscroll-behavior.
ScrollbarStyles scrollbarStyles = GetScrollbarStylesFromFrame();
if (scrollbarStyles.mOverscrollBehaviorX != StyleOverscrollBehavior::Auto ||
scrollbarStyles.mOverscrollBehaviorY != StyleOverscrollBehavior::Auto) {
ScrollStyles scrollStyles = GetScrollStylesFromFrame();
if (scrollStyles.mOverscrollBehaviorX != StyleOverscrollBehavior::Auto ||
scrollStyles.mOverscrollBehaviorY != StyleOverscrollBehavior::Auto) {
info |= CompositorHitTestInfo::eRequiresTargetConfirmation;
}
nsDisplayCompositorHitTestInfo* hitInfo =
@ -3999,21 +3999,21 @@ static void HandleScrollPref(nsIScrollable *aScrollable, int32_t aOrientation,
}
}
ScrollbarStyles
ScrollFrameHelper::GetScrollbarStylesFromFrame() const
ScrollStyles
ScrollFrameHelper::GetScrollStylesFromFrame() const
{
nsPresContext* presContext = mOuter->PresContext();
if (!presContext->IsDynamic() &&
!(mIsRoot && presContext->HasPaginatedScrolling())) {
return ScrollbarStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
return ScrollStyles(NS_STYLE_OVERFLOW_HIDDEN, NS_STYLE_OVERFLOW_HIDDEN);
}
if (!mIsRoot) {
const nsStyleDisplay* disp = mOuter->StyleDisplay();
return ScrollbarStyles(disp);
return ScrollStyles(disp);
}
ScrollbarStyles result = presContext->GetViewportScrollbarStylesOverride();
ScrollStyles result = presContext->GetViewportScrollStylesOverride();
nsCOMPtr<nsISupports> container = presContext->GetContainerWeak();
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(container);
if (scrollable) {
@ -4182,7 +4182,7 @@ ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
nsPoint newPos = mDestination + nsPoint(aDelta.x*deltaMultiplier.width, aDelta.y*deltaMultiplier.height);
if (aSnap == nsIScrollableFrame::ENABLE_SNAP) {
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
ScrollStyles styles = GetScrollStylesFromFrame();
if (styles.mScrollSnapTypeY != NS_STYLE_SCROLL_SNAP_TYPE_NONE ||
styles.mScrollSnapTypeX != NS_STYLE_SCROLL_SNAP_TYPE_NONE) {
nscoord appUnitsPerDevPixel = mOuter->PresContext()->AppUnitsPerDevPixel();
@ -4624,7 +4624,7 @@ ScrollFrameHelper::CreateAnonymousContent(
bool canHaveHorizontal;
bool canHaveVertical;
if (!mIsRoot) {
ScrollbarStyles styles = scrollable->GetScrollbarStyles();
ScrollStyles styles = scrollable->GetScrollStyles();
canHaveHorizontal = styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN;
canHaveVertical = styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN;
if (!canHaveHorizontal && !canHaveVertical && !isResizable) {
@ -5343,7 +5343,7 @@ nsXULScrollFrame::XULLayout(nsBoxLayoutState& aState)
(if we're the viewport and we added or removed a scrollbar).
**************/
ScrollbarStyles styles = GetScrollbarStyles();
ScrollStyles styles = GetScrollStyles();
// Look at our style do we always have vertical or horizontal scrollbars?
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL)
@ -5678,7 +5678,7 @@ bool
ScrollFrameHelper::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas)
{
nsIScrollableFrame* sf = do_QueryFrame(mOuter);
ScrollbarStyles ss = sf->GetScrollbarStyles();
ScrollStyles ss = sf->GetScrollStyles();
// Reflow when the change in overflow leads to one of our scrollbars
// changing or might require repositioning the scrolled content due to
@ -6404,7 +6404,7 @@ ComputeScrollSnapInfo(const ScrollFrameHelper& aScrollFrame)
{
ScrollSnapInfo result;
ScrollbarStyles styles = aScrollFrame.GetScrollbarStylesFromFrame();
ScrollStyles styles = aScrollFrame.GetScrollStylesFromFrame();
if (styles.mScrollSnapTypeY == NS_STYLE_SCROLL_SNAP_TYPE_NONE &&
styles.mScrollSnapTypeX == NS_STYLE_SCROLL_SNAP_TYPE_NONE) {

View File

@ -58,7 +58,7 @@ public:
ScrollFrameHelper(nsContainerFrame* aOuter, bool aIsRoot);
~ScrollFrameHelper();
mozilla::ScrollbarStyles GetScrollbarStylesFromFrame() const;
mozilla::ScrollStyles GetScrollStylesFromFrame() const;
// If a child frame was added or removed on the scrollframe,
// reload our child frame list.
@ -815,8 +815,8 @@ public:
virtual nsIFrame* GetScrolledFrame() const override {
return mHelper.GetScrolledFrame();
}
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const override {
return mHelper.GetScrollbarStylesFromFrame();
virtual mozilla::ScrollStyles GetScrollStyles() const override {
return mHelper.GetScrollStylesFromFrame();
}
virtual uint32_t GetScrollbarVisibility() const override {
return mHelper.GetScrollbarVisibility();
@ -1267,8 +1267,8 @@ public:
virtual nsIFrame* GetScrolledFrame() const override {
return mHelper.GetScrolledFrame();
}
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const override {
return mHelper.GetScrollbarStylesFromFrame();
virtual mozilla::ScrollStyles GetScrollStyles() const override {
return mHelper.GetScrollStylesFromFrame();
}
virtual uint32_t GetScrollbarVisibility() const override {
return mHelper.GetScrollbarVisibility();

View File

@ -13,8 +13,8 @@
#include "nsCoord.h"
#include "DisplayItemClip.h"
#include "ScrollbarStyles.h"
#include "mozilla/Maybe.h"
#include "mozilla/ScrollStyles.h"
#include "mozilla/gfx/Point.h"
#include "nsIScrollbarMediator.h"
#include "Units.h"
@ -65,7 +65,7 @@ public:
* or NS_STYLE_OVERFLOW_AUTO) governing the horizontal and vertical
* scrollbars for this frame.
*/
virtual mozilla::ScrollbarStyles GetScrollbarStyles() const = 0;
virtual mozilla::ScrollStyles GetScrollStyles() const = 0;
enum { HORIZONTAL = 0x01, VERTICAL = 0x02 };
/**