mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Move ScrollDirection to LayersTypes.h and make it a proper enum. (bug 1332567 part 1, r=kats)
This commit is contained in:
parent
5c55b07334
commit
baf1f78d98
@ -409,7 +409,7 @@ public:
|
||||
return EventRegionsOverride::NoOverride;
|
||||
}
|
||||
|
||||
Layer::ScrollDirection GetScrollbarDirection() const
|
||||
ScrollDirection GetScrollbarDirection() const
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
|
||||
@ -425,7 +425,7 @@ public:
|
||||
|
||||
int32_t GetScrollThumbLength() const
|
||||
{
|
||||
if (GetScrollbarDirection() == Layer::VERTICAL) {
|
||||
if (GetScrollbarDirection() == ScrollDirection::VERTICAL) {
|
||||
return mLayer->GetVisibleRegion().GetBounds().height;
|
||||
} else {
|
||||
return mLayer->GetVisibleRegion().GetBounds().width;
|
||||
|
@ -2109,10 +2109,10 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
||||
if (IsScrollbarContainer()) {
|
||||
aStream << " [scrollbar]";
|
||||
}
|
||||
if (GetScrollbarDirection() == VERTICAL) {
|
||||
if (GetScrollbarDirection() == ScrollDirection::VERTICAL) {
|
||||
aStream << nsPrintfCString(" [vscrollbar=%lld]", GetScrollbarTargetContainerId()).get();
|
||||
}
|
||||
if (GetScrollbarDirection() == HORIZONTAL) {
|
||||
if (GetScrollbarDirection() == ScrollDirection::HORIZONTAL) {
|
||||
aStream << nsPrintfCString(" [hscrollbar=%lld]", GetScrollbarTargetContainerId()).get();
|
||||
}
|
||||
if (GetIsFixedPosition()) {
|
||||
@ -2251,8 +2251,8 @@ Layer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
|
||||
// Component alpha
|
||||
layer->set_calpha(static_cast<bool>(GetContentFlags() & CONTENT_COMPONENT_ALPHA));
|
||||
// Vertical or horizontal bar
|
||||
if (GetScrollbarDirection() != NONE) {
|
||||
layer->set_direct(GetScrollbarDirection() == VERTICAL ?
|
||||
if (GetScrollbarDirection() != ScrollDirection::NONE) {
|
||||
layer->set_direct(GetScrollbarDirection() == ScrollDirection::VERTICAL ?
|
||||
LayersPacket::Layer::VERTICAL :
|
||||
LayersPacket::Layer::HORIZONTAL);
|
||||
layer->set_barid(GetScrollbarTargetContainerId());
|
||||
|
@ -1277,12 +1277,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
enum ScrollDirection {
|
||||
NONE,
|
||||
VERTICAL,
|
||||
HORIZONTAL
|
||||
};
|
||||
|
||||
/**
|
||||
* CONSTRUCTION PHASE ONLY
|
||||
* If a layer is a scrollbar layer, |aScrollId| holds the scroll identifier
|
||||
|
@ -309,6 +309,12 @@ private:
|
||||
uint64_t mHandle;
|
||||
};
|
||||
|
||||
enum class ScrollDirection : uint32_t {
|
||||
NONE,
|
||||
VERTICAL,
|
||||
HORIZONTAL
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -89,11 +89,11 @@ AndroidFlingAnimation::AndroidFlingAnimation(AsyncPanZoomController& aApzc,
|
||||
// (in this APZC, or an APZC further in the handoff chain).
|
||||
// This ensures that we don't take the 'overscroll' path in Sample()
|
||||
// on account of one axis which can't scroll having a velocity.
|
||||
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, Layer::HORIZONTAL)) {
|
||||
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, ScrollDirection::HORIZONTAL)) {
|
||||
ReentrantMonitorAutoEnter lock(mApzc.mMonitor);
|
||||
mApzc.mX.SetVelocity(0);
|
||||
}
|
||||
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, Layer::VERTICAL)) {
|
||||
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, ScrollDirection::VERTICAL)) {
|
||||
ReentrantMonitorAutoEnter lock(mApzc.mMonitor);
|
||||
mApzc.mY.SetVelocity(0);
|
||||
}
|
||||
|
@ -1656,12 +1656,12 @@ AsyncPanZoomController::CanScrollWithWheel(const ParentLayerPoint& aDelta) const
|
||||
}
|
||||
|
||||
bool
|
||||
AsyncPanZoomController::CanScroll(Layer::ScrollDirection aDirection) const
|
||||
AsyncPanZoomController::CanScroll(ScrollDirection aDirection) const
|
||||
{
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
switch (aDirection) {
|
||||
case Layer::HORIZONTAL: return mX.CanScroll();
|
||||
case Layer::VERTICAL: return mY.CanScroll();
|
||||
case ScrollDirection::HORIZONTAL: return mX.CanScroll();
|
||||
case ScrollDirection::VERTICAL: return mY.CanScroll();
|
||||
default: MOZ_ASSERT(false); return false;
|
||||
}
|
||||
}
|
||||
@ -1974,10 +1974,10 @@ nsEventStatus AsyncPanZoomController::OnPanEnd(const PanGestureInput& aEvent) {
|
||||
MOZ_ASSERT(GetCurrentPanGestureBlock());
|
||||
RefPtr<const OverscrollHandoffChain> overscrollHandoffChain =
|
||||
GetCurrentPanGestureBlock()->GetOverscrollHandoffChain();
|
||||
if (!overscrollHandoffChain->CanScrollInDirection(this, Layer::HORIZONTAL)) {
|
||||
if (!overscrollHandoffChain->CanScrollInDirection(this, ScrollDirection::HORIZONTAL)) {
|
||||
mX.SetVelocity(0);
|
||||
}
|
||||
if (!overscrollHandoffChain->CanScrollInDirection(this, Layer::VERTICAL)) {
|
||||
if (!overscrollHandoffChain->CanScrollInDirection(this, ScrollDirection::VERTICAL)) {
|
||||
mY.SetVelocity(0);
|
||||
}
|
||||
|
||||
@ -2264,9 +2264,9 @@ void AsyncPanZoomController::HandlePanning(double aAngle) {
|
||||
RefPtr<const OverscrollHandoffChain> overscrollHandoffChain =
|
||||
GetCurrentInputBlock()->GetOverscrollHandoffChain();
|
||||
bool canScrollHorizontal = !mX.IsAxisLocked() &&
|
||||
overscrollHandoffChain->CanScrollInDirection(this, Layer::HORIZONTAL);
|
||||
overscrollHandoffChain->CanScrollInDirection(this, ScrollDirection::HORIZONTAL);
|
||||
bool canScrollVertical = !mY.IsAxisLocked() &&
|
||||
overscrollHandoffChain->CanScrollInDirection(this, Layer::VERTICAL);
|
||||
overscrollHandoffChain->CanScrollInDirection(this, ScrollDirection::VERTICAL);
|
||||
|
||||
if (!canScrollHorizontal || !canScrollVertical) {
|
||||
SetState(PANNING);
|
||||
|
@ -394,7 +394,7 @@ public:
|
||||
|
||||
// Return whether or not there is room to scroll this APZC
|
||||
// in the given direction.
|
||||
bool CanScroll(Layer::ScrollDirection aDirection) const;
|
||||
bool CanScroll(ScrollDirection aDirection) const;
|
||||
|
||||
void NotifyMozMouseScrollEvent(const nsString& aString) const;
|
||||
|
||||
|
@ -45,11 +45,11 @@ public:
|
||||
// (in this APZC, or an APZC further in the handoff chain).
|
||||
// This ensures that we don't take the 'overscroll' path in Sample()
|
||||
// on account of one axis which can't scroll having a velocity.
|
||||
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, Layer::HORIZONTAL)) {
|
||||
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, ScrollDirection::HORIZONTAL)) {
|
||||
ReentrantMonitorAutoEnter lock(mApzc.mMonitor);
|
||||
mApzc.mX.SetVelocity(0);
|
||||
}
|
||||
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, Layer::VERTICAL)) {
|
||||
if (!mOverscrollHandoffChain->CanScrollInDirection(&mApzc, ScrollDirection::VERTICAL)) {
|
||||
ReentrantMonitorAutoEnter lock(mApzc.mMonitor);
|
||||
mApzc.mY.SetVelocity(0);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ HitTestingTreeNode::HitTestingTreeNode(AsyncPanZoomController* aApzc,
|
||||
, mIsPrimaryApzcHolder(aIsPrimaryHolder)
|
||||
, mLayersId(aLayersId)
|
||||
, mScrollViewId(FrameMetrics::NULL_SCROLL_ID)
|
||||
, mScrollDir(Layer::NONE)
|
||||
, mScrollDir(ScrollDirection::NONE)
|
||||
, mScrollThumbLength(0)
|
||||
, mIsScrollbarContainer(false)
|
||||
, mFixedPosTarget(FrameMetrics::NULL_SCROLL_ID)
|
||||
@ -95,7 +95,7 @@ HitTestingTreeNode::SetLastChild(HitTestingTreeNode* aChild)
|
||||
|
||||
void
|
||||
HitTestingTreeNode::SetScrollbarData(FrameMetrics::ViewID aScrollViewId,
|
||||
Layer::ScrollDirection aDir,
|
||||
ScrollDirection aDir,
|
||||
int32_t aScrollThumbLength,
|
||||
bool aIsScrollContainer)
|
||||
{
|
||||
@ -108,9 +108,9 @@ HitTestingTreeNode::SetScrollbarData(FrameMetrics::ViewID aScrollViewId,
|
||||
bool
|
||||
HitTestingTreeNode::MatchesScrollDragMetrics(const AsyncDragMetrics& aDragMetrics) const
|
||||
{
|
||||
return ((mScrollDir == Layer::HORIZONTAL &&
|
||||
return ((mScrollDir == ScrollDirection::HORIZONTAL &&
|
||||
aDragMetrics.mDirection == AsyncDragMetrics::HORIZONTAL) ||
|
||||
(mScrollDir == Layer::VERTICAL &&
|
||||
(mScrollDir == ScrollDirection::VERTICAL &&
|
||||
aDragMetrics.mDirection == AsyncDragMetrics::VERTICAL)) &&
|
||||
mScrollViewId == aDragMetrics.mViewId;
|
||||
}
|
||||
@ -124,7 +124,7 @@ HitTestingTreeNode::GetScrollThumbLength() const
|
||||
bool
|
||||
HitTestingTreeNode::IsScrollbarNode() const
|
||||
{
|
||||
return mIsScrollbarContainer || (mScrollDir != Layer::NONE);
|
||||
return mIsScrollbarContainer || (mScrollDir != ScrollDirection::NONE);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -92,7 +92,7 @@ public:
|
||||
/* Scrollbar info */
|
||||
|
||||
void SetScrollbarData(FrameMetrics::ViewID aScrollViewId,
|
||||
Layer::ScrollDirection aDir,
|
||||
ScrollDirection aDir,
|
||||
int32_t aScrollThumbLength,
|
||||
bool aIsScrollContainer);
|
||||
bool MatchesScrollDragMetrics(const AsyncDragMetrics& aDragMetrics) const;
|
||||
@ -129,7 +129,7 @@ private:
|
||||
uint64_t mLayersId;
|
||||
|
||||
FrameMetrics::ViewID mScrollViewId;
|
||||
Layer::ScrollDirection mScrollDir;
|
||||
ScrollDirection mScrollDir;
|
||||
int32_t mScrollThumbLength;
|
||||
bool mIsScrollbarContainer;
|
||||
|
||||
|
@ -132,7 +132,7 @@ OverscrollHandoffChain::CanBePanned(const AsyncPanZoomController* aApzc) const
|
||||
|
||||
bool
|
||||
OverscrollHandoffChain::CanScrollInDirection(const AsyncPanZoomController* aApzc,
|
||||
Layer::ScrollDirection aDirection) const
|
||||
ScrollDirection aDirection) const
|
||||
{
|
||||
// Find |aApzc| in the handoff chain.
|
||||
uint32_t i = IndexOf(aApzc);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "mozilla/RefPtr.h" // for RefPtr
|
||||
#include "nsISupportsImpl.h" // for NS_INLINE_DECL_THREADSAFE_REFCOUNTING
|
||||
#include "APZUtils.h" // for CancelAnimationFlags
|
||||
#include "Layers.h" // for Layer::ScrollDirection
|
||||
#include "mozilla/layers/LayersTypes.h" // for Layer::ScrollDirection
|
||||
#include "Units.h" // for ScreenPoint
|
||||
|
||||
namespace mozilla {
|
||||
@ -81,7 +81,7 @@ public:
|
||||
// Determine whether the given APZC, or any APZC further in the chain,
|
||||
// can scroll in the given direction.
|
||||
bool CanScrollInDirection(const AsyncPanZoomController* aApzc,
|
||||
Layer::ScrollDirection aDirection) const;
|
||||
ScrollDirection aDirection) const;
|
||||
|
||||
// Determine whether any APZC along this handoff chain is overscrolled.
|
||||
bool HasOverscrolledApzc() const;
|
||||
|
@ -933,7 +933,7 @@ MoveScrollbarForLayerMargin(Layer* aRoot, FrameMetrics::ViewID aRootScrollId,
|
||||
// adjustment on the layer tree.
|
||||
Layer* scrollbar = BreadthFirstSearch<ReverseIterator>(aRoot,
|
||||
[aRootScrollId](Layer* aNode) {
|
||||
return (aNode->GetScrollbarDirection() == Layer::HORIZONTAL &&
|
||||
return (aNode->GetScrollbarDirection() == ScrollDirection::HORIZONTAL &&
|
||||
aNode->GetScrollbarTargetContainerId() == aRootScrollId);
|
||||
});
|
||||
if (scrollbar) {
|
||||
@ -1212,7 +1212,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer,
|
||||
|
||||
ExpandRootClipRect(layer, fixedLayerMargins);
|
||||
|
||||
if (layer->GetScrollbarDirection() != Layer::NONE) {
|
||||
if (layer->GetScrollbarDirection() != ScrollDirection::NONE) {
|
||||
ApplyAsyncTransformToScrollbar(layer);
|
||||
}
|
||||
});
|
||||
@ -1260,7 +1260,7 @@ ApplyAsyncTransformToScrollbarForContent(Layer* aScrollbar,
|
||||
// on the painted content, we need to adjust it based on asyncTransform so that
|
||||
// it reflects what the user is actually seeing now.
|
||||
AsyncTransformComponentMatrix scrollbarTransform;
|
||||
if (aScrollbar->GetScrollbarDirection() == Layer::VERTICAL) {
|
||||
if (aScrollbar->GetScrollbarDirection() == ScrollDirection::VERTICAL) {
|
||||
const ParentLayerCoord asyncScrollY = asyncTransform._42;
|
||||
const float asyncZoomY = asyncTransform._22;
|
||||
|
||||
@ -1312,7 +1312,7 @@ ApplyAsyncTransformToScrollbarForContent(Layer* aScrollbar,
|
||||
scrollbarTransform.PostScale(1.f, yScale, 1.f);
|
||||
scrollbarTransform.PostTranslate(0, yTranslation, 0);
|
||||
}
|
||||
if (aScrollbar->GetScrollbarDirection() == Layer::HORIZONTAL) {
|
||||
if (aScrollbar->GetScrollbarDirection() == ScrollDirection::HORIZONTAL) {
|
||||
// See detailed comments under the VERTICAL case.
|
||||
|
||||
const ParentLayerCoord asyncScrollX = asyncTransform._41;
|
||||
|
@ -303,7 +303,7 @@ LayerTransactionParent::RecvUpdate(const TransactionInfo& aInfo,
|
||||
common.stickyScrollRangeInner());
|
||||
}
|
||||
layer->SetScrollbarData(common.scrollbarTargetContainerId(),
|
||||
static_cast<Layer::ScrollDirection>(common.scrollbarDirection()),
|
||||
static_cast<ScrollDirection>(common.scrollbarDirection()),
|
||||
common.scrollbarThumbRatio());
|
||||
if (common.isScrollbarContainer()) {
|
||||
layer->SetIsScrollbarContainer();
|
||||
|
@ -664,7 +664,7 @@ ShadowLayerForwarder::EndTransaction(const nsIntRegion& aRegionToClear,
|
||||
#endif
|
||||
}
|
||||
common.scrollbarTargetContainerId() = mutant->GetScrollbarTargetContainerId();
|
||||
common.scrollbarDirection() = mutant->GetScrollbarDirection();
|
||||
common.scrollbarDirection() = (uint32_t)mutant->GetScrollbarDirection();
|
||||
common.scrollbarThumbRatio() = mutant->GetScrollbarThumbRatio();
|
||||
common.isScrollbarContainer() = mutant->IsScrollbarContainer();
|
||||
common.mixBlendMode() = (int8_t)mutant->GetMixBlendMode();
|
||||
|
@ -5141,10 +5141,10 @@ nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
aContainerParameters, nullptr,
|
||||
FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR);
|
||||
if (mFlags & VERTICAL_SCROLLBAR) {
|
||||
layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::VERTICAL, mScrollbarThumbRatio);
|
||||
layer->SetScrollbarData(mScrollTarget, ScrollDirection::VERTICAL, mScrollbarThumbRatio);
|
||||
}
|
||||
if (mFlags & HORIZONTAL_SCROLLBAR) {
|
||||
layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::HORIZONTAL, mScrollbarThumbRatio);
|
||||
layer->SetScrollbarData(mScrollTarget, ScrollDirection::HORIZONTAL, mScrollbarThumbRatio);
|
||||
}
|
||||
if (mFlags & SCROLLBAR_CONTAINER) {
|
||||
layer->SetIsScrollbarContainer();
|
||||
|
Loading…
Reference in New Issue
Block a user