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 "nsPrintfCString.h" // for nsPrintfCString
16 ScrollableLayerGuid::ScrollableLayerGuid()
17 : mLayersId
{0}, mPresShellId(0), mScrollId(0) {}
19 ScrollableLayerGuid::ScrollableLayerGuid(LayersId aLayersId
,
20 uint32_t aPresShellId
,
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
) {
37 if (mLayersId
== other
.mLayersId
) {
38 if (mPresShellId
< other
.mPresShellId
) {
41 if (mPresShellId
== other
.mPresShellId
) {
42 return mScrollId
< other
.mScrollId
;
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
,
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
,
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
);
77 } // namespace mozilla