summaryrefslogtreecommitdiffstats
path: root/layout/base/ScrollStyles.h
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-01-06 16:31:36 +0000
committerMoonchild <moonchild@palemoon.org>2021-01-06 16:31:36 +0000
commit0e6a9cc60aeb754e00e466ce20052d2fa9ccb7f9 (patch)
treeec4cb347e7cb522e098115abf09e7d2652366148 /layout/base/ScrollStyles.h
parent4681e04dc5263a6cbb3f76ae20b0e44509bfee7b (diff)
downloadUXP-0e6a9cc60aeb754e00e466ce20052d2fa9ccb7f9.tar
UXP-0e6a9cc60aeb754e00e466ce20052d2fa9ccb7f9.tar.gz
UXP-0e6a9cc60aeb754e00e466ce20052d2fa9ccb7f9.tar.lz
UXP-0e6a9cc60aeb754e00e466ce20052d2fa9ccb7f9.tar.xz
UXP-0e6a9cc60aeb754e00e466ce20052d2fa9ccb7f9.zip
Issue #1705 - Part 3: Rename ScrollbarStyles to ScrollStyles.
ScrollbarStyles contains values of overflow, (over)scroll-behavior, etc. The only one which is marginally related to scroll _bars_ is overflow, which can be used to hide scrollbar (by making an element not scrollable) or enforce the scrollbar to display. It makes more sense to be called ScrollStyles as it's mainly concerning behavior of scrolling, not scrollbars. Also, with the addition of scrollbar width properties, the current name can be confusing.
Diffstat (limited to 'layout/base/ScrollStyles.h')
-rw-r--r--layout/base/ScrollStyles.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/layout/base/ScrollStyles.h b/layout/base/ScrollStyles.h
new file mode 100644
index 000000000..c5743ee6b
--- /dev/null
+++ b/layout/base/ScrollStyles.h
@@ -0,0 +1,82 @@
+/* -*- 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 ScrollStyles_h
+#define ScrollStyles_h
+
+#include <stdint.h>
+#include "nsStyleConsts.h" // for NS_STYLE_SCROLL_SNAP_*
+#include "nsStyleCoord.h" // for nsStyleCoord
+#include "mozilla/dom/WindowBinding.h"
+
+// Forward declarations
+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 NS_STYLE_SCROLL_BEHAVIOR_AUTO or
+ // NS_STYLE_SCROLL_BEHAVIOR_SMOOTH
+ uint8_t mScrollBehavior;
+ // 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;
+
+ ScrollStyles(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 ScrollStyles(const nsStyleDisplay* aDisplay);
+ ScrollStyles(uint8_t aH, uint8_t aV, const nsStyleDisplay* aDisplay);
+ ScrollStyles() {}
+ bool operator==(const ScrollStyles& aStyles) const {
+ return aStyles.mHorizontal == mHorizontal && aStyles.mVertical == mVertical &&
+ aStyles.mScrollBehavior == mScrollBehavior &&
+ aStyles.mScrollSnapTypeX == mScrollSnapTypeX &&
+ aStyles.mScrollSnapTypeY == mScrollSnapTypeY &&
+ aStyles.mScrollSnapPointsX == mScrollSnapPointsX &&
+ aStyles.mScrollSnapPointsY == mScrollSnapPointsY &&
+ aStyles.mScrollSnapDestinationX == mScrollSnapDestinationX &&
+ aStyles.mScrollSnapDestinationY == mScrollSnapDestinationY;
+ }
+ bool operator!=(const ScrollStyles& aStyles) const {
+ return !(*this == aStyles);
+ }
+ bool IsHiddenInBothDirections() const {
+ return mHorizontal == NS_STYLE_OVERFLOW_HIDDEN &&
+ mVertical == NS_STYLE_OVERFLOW_HIDDEN;
+ }
+ bool IsSmoothScroll(dom::ScrollBehavior aBehavior) const {
+ return aBehavior == dom::ScrollBehavior::Smooth ||
+ (aBehavior == dom::ScrollBehavior::Auto &&
+ mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH);
+ }
+};
+
+} // namespace mozilla
+
+#endif