Bug 1876335 - use GRADLE_MAVEN_REPOSITORIES in more places. r=owlish,geckoview-review...
[gecko.git] / gfx / layers / ScrollableLayerGuid.cpp
blob914a8ad124d46c143e6231d7c34e2bae98cbdfe9
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "ScrollableLayerGuid.h"
9 #include <ostream>
10 #include "mozilla/HashFunctions.h" // for HashGeneric
11 #include "nsPrintfCString.h" // for nsPrintfCString
13 namespace mozilla {
14 namespace layers {
16 ScrollableLayerGuid::ScrollableLayerGuid()
17 : mLayersId{0}, mPresShellId(0), mScrollId(0) {}
19 ScrollableLayerGuid::ScrollableLayerGuid(LayersId aLayersId,
20 uint32_t aPresShellId,
21 ViewID aScrollId)
22 : mLayersId(aLayersId), mPresShellId(aPresShellId), mScrollId(aScrollId) {}
24 bool ScrollableLayerGuid::operator==(const ScrollableLayerGuid& other) const {
25 return mLayersId == other.mLayersId && mPresShellId == other.mPresShellId &&
26 mScrollId == other.mScrollId;
29 bool ScrollableLayerGuid::operator!=(const ScrollableLayerGuid& other) const {
30 return !(*this == other);
33 bool ScrollableLayerGuid::operator<(const ScrollableLayerGuid& other) const {
34 if (mLayersId < other.mLayersId) {
35 return true;
37 if (mLayersId == other.mLayersId) {
38 if (mPresShellId < other.mPresShellId) {
39 return true;
41 if (mPresShellId == other.mPresShellId) {
42 return mScrollId < other.mScrollId;
45 return false;
48 std::ostream& operator<<(std::ostream& aOut, const ScrollableLayerGuid& aGuid) {
49 return aOut << nsPrintfCString("{ l=0x%" PRIx64 ", p=%u, v=%" PRIu64 " }",
50 uint64_t(aGuid.mLayersId), aGuid.mPresShellId,
51 aGuid.mScrollId)
52 .get();
55 bool ScrollableLayerGuid::EqualsIgnoringPresShell(
56 const ScrollableLayerGuid& aA, const ScrollableLayerGuid& aB) {
57 return aA.mLayersId == aB.mLayersId && aA.mScrollId == aB.mScrollId;
60 std::size_t ScrollableLayerGuid::HashFn::operator()(
61 const ScrollableLayerGuid& aGuid) const {
62 return HashGeneric(uint64_t(aGuid.mLayersId), aGuid.mPresShellId,
63 aGuid.mScrollId);
66 std::size_t ScrollableLayerGuid::HashIgnoringPresShellFn::operator()(
67 const ScrollableLayerGuid& aGuid) const {
68 return HashGeneric(uint64_t(aGuid.mLayersId), aGuid.mScrollId);
71 bool ScrollableLayerGuid::EqualIgnoringPresShellFn::operator()(
72 const ScrollableLayerGuid& lhs, const ScrollableLayerGuid& rhs) const {
73 return EqualsIgnoringPresShell(lhs, rhs);
76 } // namespace layers
77 } // namespace mozilla