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"
10 #include "mozilla/HashFunctions.h" // for HashGeneric
11 #include "mozilla/IntegerPrintfMacros.h"
12 #include "nsPrintfCString.h" // for nsPrintfCString
17 ScrollableLayerGuid::ScrollableLayerGuid()
18 : mLayersId
{0}, mPresShellId(0), mScrollId(0) {}
20 ScrollableLayerGuid::ScrollableLayerGuid(LayersId aLayersId
,
21 uint32_t aPresShellId
,
23 : mLayersId(aLayersId
), mPresShellId(aPresShellId
), mScrollId(aScrollId
) {}
25 bool ScrollableLayerGuid::operator==(const ScrollableLayerGuid
& other
) const {
26 return mLayersId
== other
.mLayersId
&& mPresShellId
== other
.mPresShellId
&&
27 mScrollId
== other
.mScrollId
;
30 bool ScrollableLayerGuid::operator!=(const ScrollableLayerGuid
& other
) const {
31 return !(*this == other
);
34 bool ScrollableLayerGuid::operator<(const ScrollableLayerGuid
& other
) const {
35 if (mLayersId
< other
.mLayersId
) {
38 if (mLayersId
== other
.mLayersId
) {
39 if (mPresShellId
< other
.mPresShellId
) {
42 if (mPresShellId
== other
.mPresShellId
) {
43 return mScrollId
< other
.mScrollId
;
49 std::ostream
& operator<<(std::ostream
& aOut
, const ScrollableLayerGuid
& aGuid
) {
50 return aOut
<< nsPrintfCString("{ l=0x%" PRIx64
", p=%u, v=%" PRIu64
" }",
51 uint64_t(aGuid
.mLayersId
), aGuid
.mPresShellId
,
56 bool ScrollableLayerGuid::EqualsIgnoringPresShell(
57 const ScrollableLayerGuid
& aA
, const ScrollableLayerGuid
& aB
) {
58 return aA
.mLayersId
== aB
.mLayersId
&& aA
.mScrollId
== aB
.mScrollId
;
61 std::size_t ScrollableLayerGuid::HashFn::operator()(
62 const ScrollableLayerGuid
& aGuid
) const {
63 return HashGeneric(uint64_t(aGuid
.mLayersId
), aGuid
.mPresShellId
,
67 std::size_t ScrollableLayerGuid::HashIgnoringPresShellFn::operator()(
68 const ScrollableLayerGuid
& aGuid
) const {
69 return HashGeneric(uint64_t(aGuid
.mLayersId
), aGuid
.mScrollId
);
72 bool ScrollableLayerGuid::EqualIgnoringPresShellFn::operator()(
73 const ScrollableLayerGuid
& lhs
, const ScrollableLayerGuid
& rhs
) const {
74 return EqualsIgnoringPresShell(lhs
, rhs
);
78 } // namespace mozilla