2013-08-23 20:20:07 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2014-02-04 01:54:22 +00:00
|
|
|
#include "nsStyleConsts.h" // for NS_STYLE_SCROLL_SNAP_*
|
|
|
|
#include "nsStyleCoord.h" // for nsStyleCoord
|
2014-09-15 19:30:03 +00:00
|
|
|
#include "mozilla/dom/WindowBinding.h"
|
2013-08-23 20:20:07 +00:00
|
|
|
|
2014-02-04 01:54:22 +00:00
|
|
|
// Forward declarations
|
|
|
|
struct nsStyleDisplay;
|
|
|
|
|
2013-08-23 20:20:07 +00:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
struct ScrollbarStyles
|
|
|
|
{
|
|
|
|
// Always one of NS_STYLE_OVERFLOW_SCROLL, NS_STYLE_OVERFLOW_HIDDEN,
|
|
|
|
// or NS_STYLE_OVERFLOW_AUTO.
|
|
|
|
uint8_t mHorizontal;
|
|
|
|
uint8_t mVertical;
|
2014-10-22 09:37:00 +00:00
|
|
|
// Always one of NS_STYLE_SCROLL_BEHAVIOR_AUTO or
|
2014-09-15 19:30:00 +00:00
|
|
|
// NS_STYLE_SCROLL_BEHAVIOR_SMOOTH
|
|
|
|
uint8_t mScrollBehavior;
|
2014-02-04 01:54:22 +00:00
|
|
|
// Always one of NS_STYLE_SCROLL_SNAP_NONE, NS_STYLE_SCROLL_SNAP_MANDATORY,
|
|
|
|
// or NS_STYLE_SCROLL_SNAP_PROXIMITY.
|
|
|
|
uint8_t mScrollSnapTypeX;
|
|
|
|
uint8_t mScrollSnapTypeY;
|
|
|
|
nsStyleCoord mScrollSnapPointsX;
|
|
|
|
nsStyleCoord mScrollSnapPointsY;
|
|
|
|
nsStyleCoord::CalcValue mScrollSnapDestinationX;
|
|
|
|
nsStyleCoord::CalcValue mScrollSnapDestinationY;
|
|
|
|
|
|
|
|
ScrollbarStyles(uint8_t aH, uint8_t aV)
|
|
|
|
: mHorizontal(aH), mVertical(aV),
|
|
|
|
mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO),
|
|
|
|
mScrollSnapTypeX(NS_STYLE_SCROLL_SNAP_TYPE_NONE),
|
|
|
|
mScrollSnapTypeY(NS_STYLE_SCROLL_SNAP_TYPE_NONE),
|
|
|
|
mScrollSnapPointsX(nsStyleCoord(eStyleUnit_None)),
|
|
|
|
mScrollSnapPointsY(nsStyleCoord(eStyleUnit_None)) {
|
|
|
|
|
|
|
|
mScrollSnapDestinationX.mPercent = 0;
|
|
|
|
mScrollSnapDestinationX.mLength = nscoord(0.0f);
|
|
|
|
mScrollSnapDestinationX.mHasPercent = false;
|
|
|
|
mScrollSnapDestinationY.mPercent = 0;
|
|
|
|
mScrollSnapDestinationY.mLength = nscoord(0.0f);
|
|
|
|
mScrollSnapDestinationY.mHasPercent = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
explicit ScrollbarStyles(const nsStyleDisplay* aDisplay);
|
|
|
|
ScrollbarStyles(uint8_t aH, uint8_t aV, const nsStyleDisplay* aDisplay);
|
2013-08-23 20:20:07 +00:00
|
|
|
bool operator==(const ScrollbarStyles& aStyles) const {
|
2014-09-15 19:30:00 +00:00
|
|
|
return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical &&
|
2014-02-04 01:54:22 +00:00
|
|
|
aStyles.mScrollBehavior == mScrollBehavior &&
|
|
|
|
aStyles.mScrollSnapTypeX == mScrollSnapTypeX &&
|
|
|
|
aStyles.mScrollSnapTypeY == mScrollSnapTypeY &&
|
|
|
|
aStyles.mScrollSnapPointsX == mScrollSnapPointsX &&
|
|
|
|
aStyles.mScrollSnapPointsY == mScrollSnapPointsY &&
|
|
|
|
aStyles.mScrollSnapDestinationX == mScrollSnapDestinationX &&
|
|
|
|
aStyles.mScrollSnapDestinationY == mScrollSnapDestinationY;
|
2013-08-23 20:20:07 +00:00
|
|
|
}
|
|
|
|
bool operator!=(const ScrollbarStyles& aStyles) const {
|
2014-02-04 01:54:22 +00:00
|
|
|
return !(*this == aStyles);
|
2014-09-15 19:30:00 +00:00
|
|
|
}
|
2014-09-15 19:30:03 +00:00
|
|
|
bool IsHiddenInBothDirections() const {
|
2014-09-15 19:30:00 +00:00
|
|
|
return mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
|
|
|
|
mVertical == NS_STYLE_OVERFLOW_HIDDEN;
|
2013-08-23 20:20:07 +00:00
|
|
|
}
|
2014-09-15 19:30:03 +00:00
|
|
|
bool IsSmoothScroll(dom::ScrollBehavior aBehavior) const {
|
|
|
|
return aBehavior == dom::ScrollBehavior::Smooth ||
|
|
|
|
(aBehavior == dom::ScrollBehavior::Auto &&
|
|
|
|
mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH);
|
|
|
|
}
|
2013-08-23 20:20:07 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace mozilla
|
2013-08-23 20:20:07 +00:00
|
|
|
|
|
|
|
#endif
|