gecko-dev/layout/base/ScrollbarStyles.h
Daniel Holbert 680815cd6e Bug 1412346 part 5: (automated patch) Switch a bunch of C++ files in layout to use our standard mode lines. r=jfkthame
This patch was generated automatically by the "modeline.py" script, available
here: https://github.com/amccreight/moz-source-tools/blob/master/modeline.py

For every file that is modified in this patch, the changes are as follows:
 (1) The patch changes the file to use the exact C++ mode lines from the
     Mozilla coding style guide, available here:
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Mode_Line

 (2) The patch deletes any blank lines between the mode line & the MPL
     boilerplate comment.

 (3) If the file previously had the mode lines and MPL boilerplate in a
     single contiguous C++ comment, then the patch splits them into
     separate C++ comments, to match the boilerplate in the coding style.

MozReview-Commit-ID: EuRsDue63tK

--HG--
extra : rebase_source : 3356d4b80ff6213935192e87cdbc9103fec6084c
2017-10-27 10:33:53 -07:00

83 lines
3.1 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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>
#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 ScrollbarStyles
{
// 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;
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);
bool operator==(const ScrollbarStyles& 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 ScrollbarStyles& 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