2017-10-27 23:10:06 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2017-01-25 00:41:18 +00:00
|
|
|
/* 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/. */
|
2018-03-02 18:00:03 +00:00
|
|
|
|
2017-01-25 00:41:18 +00:00
|
|
|
#ifndef mozilla_gfx_layers_LayerAttributes_h
|
|
|
|
#define mozilla_gfx_layers_LayerAttributes_h
|
|
|
|
|
2019-10-07 21:04:24 +00:00
|
|
|
#include "FrameMetrics.h"
|
2017-11-21 00:00:34 +00:00
|
|
|
#include "mozilla/Maybe.h"
|
2017-01-25 00:41:18 +00:00
|
|
|
#include "mozilla/gfx/Types.h"
|
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2019-10-07 21:04:24 +00:00
|
|
|
#include "mozilla/layers/ScrollableLayerGuid.h"
|
2017-01-25 00:41:18 +00:00
|
|
|
|
2017-01-25 00:41:18 +00:00
|
|
|
namespace IPC {
|
|
|
|
template <typename T>
|
|
|
|
struct ParamTraits;
|
|
|
|
} // namespace IPC
|
|
|
|
|
2017-01-25 00:41:18 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2020-03-13 19:48:47 +00:00
|
|
|
// clang-format off
|
|
|
|
MOZ_DEFINE_ENUM_CLASS_WITH_BASE(ScrollbarLayerType, uint8_t, (
|
|
|
|
None,
|
|
|
|
Thumb,
|
|
|
|
Container
|
|
|
|
));
|
|
|
|
// clang-format on
|
2018-03-02 18:00:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* It stores data for scroll thumb layer or container layers.
|
|
|
|
*/
|
|
|
|
struct ScrollbarData {
|
2018-05-25 05:20:39 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* This constructor is for Thumb layer type.
|
|
|
|
*/
|
2018-03-02 18:00:03 +00:00
|
|
|
ScrollbarData(ScrollDirection aDirection, float aThumbRatio,
|
|
|
|
CSSCoord aThumbStart, CSSCoord aThumbLength,
|
|
|
|
bool aThumbIsAsyncDraggable, CSSCoord aScrollTrackStart,
|
2018-04-14 07:42:45 +00:00
|
|
|
CSSCoord aScrollTrackLength, uint64_t aTargetViewId)
|
2017-11-21 00:00:34 +00:00
|
|
|
: mDirection(Some(aDirection)),
|
2018-05-25 05:20:39 +00:00
|
|
|
mScrollbarLayerType(ScrollbarLayerType::Thumb),
|
2017-05-04 00:37:14 +00:00
|
|
|
mThumbRatio(aThumbRatio),
|
2017-05-10 23:24:26 +00:00
|
|
|
mThumbStart(aThumbStart),
|
2017-05-04 00:37:14 +00:00
|
|
|
mThumbLength(aThumbLength),
|
2018-03-02 18:00:03 +00:00
|
|
|
mThumbIsAsyncDraggable(aThumbIsAsyncDraggable),
|
2017-05-05 19:54:27 +00:00
|
|
|
mScrollTrackStart(aScrollTrackStart),
|
|
|
|
mScrollTrackLength(aScrollTrackLength),
|
2018-04-14 07:42:45 +00:00
|
|
|
mTargetViewId(aTargetViewId) {}
|
2017-05-10 18:02:15 +00:00
|
|
|
|
2018-05-25 05:20:39 +00:00
|
|
|
/**
|
|
|
|
* This constructor is for Container layer type.
|
|
|
|
*/
|
|
|
|
ScrollbarData(const Maybe<ScrollDirection>& aDirection,
|
|
|
|
uint64_t aTargetViewId)
|
|
|
|
: mDirection(aDirection),
|
|
|
|
mScrollbarLayerType(ScrollbarLayerType::Container),
|
|
|
|
mTargetViewId(aTargetViewId) {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
ScrollbarData() = default;
|
|
|
|
|
|
|
|
static ScrollbarData CreateForThumb(ScrollDirection aDirection,
|
|
|
|
float aThumbRatio, CSSCoord aThumbStart,
|
|
|
|
CSSCoord aThumbLength,
|
|
|
|
bool aThumbIsAsyncDraggable,
|
|
|
|
CSSCoord aScrollTrackStart,
|
|
|
|
CSSCoord aScrollTrackLength,
|
|
|
|
uint64_t aTargetViewId) {
|
|
|
|
return ScrollbarData(aDirection, aThumbRatio, aThumbStart, aThumbLength,
|
|
|
|
aThumbIsAsyncDraggable, aScrollTrackStart,
|
|
|
|
aScrollTrackLength, aTargetViewId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ScrollbarData CreateForScrollbarContainer(
|
|
|
|
const Maybe<ScrollDirection>& aDirection, uint64_t aTargetViewId) {
|
|
|
|
return ScrollbarData(aDirection, aTargetViewId);
|
|
|
|
}
|
|
|
|
|
2018-03-02 18:00:03 +00:00
|
|
|
/**
|
|
|
|
* The mDirection contains a direction if mScrollbarLayerType is Thumb
|
|
|
|
* or Container, otherwise it's empty.
|
|
|
|
*/
|
2017-11-21 00:00:34 +00:00
|
|
|
Maybe<ScrollDirection> mDirection;
|
2018-03-02 18:00:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate what kind of layer this data is for. All possibilities are defined
|
|
|
|
* in enum ScrollbarLayerType
|
|
|
|
*/
|
|
|
|
ScrollbarLayerType mScrollbarLayerType = ScrollbarLayerType::None;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The scrollbar thumb ratio is the ratio of the thumb position (in the CSS
|
|
|
|
* pixels of the scrollframe's parent's space) to the scroll position (in the
|
|
|
|
* CSS pixels of the scrollframe's space).
|
|
|
|
*/
|
|
|
|
float mThumbRatio = 0.0f;
|
|
|
|
|
2017-05-10 23:24:26 +00:00
|
|
|
CSSCoord mThumbStart;
|
2017-05-04 00:37:14 +00:00
|
|
|
CSSCoord mThumbLength;
|
2018-03-02 18:00:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the scrollbar thumb can be dragged asynchronously.
|
|
|
|
*/
|
|
|
|
bool mThumbIsAsyncDraggable = false;
|
|
|
|
|
2017-05-05 19:54:27 +00:00
|
|
|
CSSCoord mScrollTrackStart;
|
|
|
|
CSSCoord mScrollTrackLength;
|
2018-11-01 20:15:46 +00:00
|
|
|
uint64_t mTargetViewId = ScrollableLayerGuid::NULL_SCROLL_ID;
|
2017-05-10 18:02:15 +00:00
|
|
|
|
2018-03-02 18:00:03 +00:00
|
|
|
bool operator==(const ScrollbarData& aOther) const {
|
2017-05-10 18:02:15 +00:00
|
|
|
return mDirection == aOther.mDirection &&
|
2018-03-02 18:00:03 +00:00
|
|
|
mScrollbarLayerType == aOther.mScrollbarLayerType &&
|
2017-05-04 00:37:14 +00:00
|
|
|
mThumbRatio == aOther.mThumbRatio &&
|
2017-05-10 23:24:26 +00:00
|
|
|
mThumbStart == aOther.mThumbStart &&
|
2017-05-05 20:17:06 +00:00
|
|
|
mThumbLength == aOther.mThumbLength &&
|
2018-03-02 18:00:03 +00:00
|
|
|
mThumbIsAsyncDraggable == aOther.mThumbIsAsyncDraggable &&
|
2017-05-05 19:54:27 +00:00
|
|
|
mScrollTrackStart == aOther.mScrollTrackStart &&
|
2018-03-02 18:00:03 +00:00
|
|
|
mScrollTrackLength == aOther.mScrollTrackLength &&
|
|
|
|
mTargetViewId == aOther.mTargetViewId;
|
2017-05-10 18:02:15 +00:00
|
|
|
}
|
2018-03-02 18:00:03 +00:00
|
|
|
bool operator!=(const ScrollbarData& aOther) const {
|
2017-05-10 18:02:15 +00:00
|
|
|
return !(*this == aOther);
|
|
|
|
}
|
2018-04-17 19:04:34 +00:00
|
|
|
|
|
|
|
bool IsThumb() const {
|
|
|
|
return mScrollbarLayerType == ScrollbarLayerType::Thumb;
|
|
|
|
}
|
2017-05-10 18:02:15 +00:00
|
|
|
};
|
|
|
|
|
2017-01-25 00:41:18 +00:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_gfx_layers_LayerAttributes_h
|