Bug 1452182 [wpt PR 9921] - [css-grid] Minimum width items should include margins...
[gecko.git] / hal / WindowIdentifier.cpp
blob8e1354ba794431ab00f7d8bea171bff3f99df083
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et ft=cpp : */
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 "WindowIdentifier.h"
9 #include "mozilla/dom/ContentChild.h"
10 #include "nsPIDOMWindow.h"
12 namespace mozilla {
13 namespace hal {
15 WindowIdentifier::WindowIdentifier()
16 : mWindow(nullptr)
17 , mIsEmpty(true)
21 WindowIdentifier::WindowIdentifier(nsPIDOMWindowInner* window)
22 : mWindow(window)
23 , mIsEmpty(false)
25 mID.AppendElement(GetWindowID());
28 WindowIdentifier::WindowIdentifier(const InfallibleTArray<uint64_t> &id,
29 nsPIDOMWindowInner* window)
30 : mID(id)
31 , mWindow(window)
32 , mIsEmpty(false)
34 mID.AppendElement(GetWindowID());
37 WindowIdentifier::WindowIdentifier(const WindowIdentifier &other)
38 : mID(other.mID)
39 , mWindow(other.mWindow)
40 , mIsEmpty(other.mIsEmpty)
44 const InfallibleTArray<uint64_t>&
45 WindowIdentifier::AsArray() const
47 MOZ_ASSERT(!mIsEmpty);
48 return mID;
51 bool
52 WindowIdentifier::HasTraveledThroughIPC() const
54 MOZ_ASSERT(!mIsEmpty);
55 return mID.Length() >= 2;
58 void
59 WindowIdentifier::AppendProcessID()
61 MOZ_ASSERT(!mIsEmpty);
62 mID.AppendElement(dom::ContentChild::GetSingleton()->GetID());
65 uint64_t
66 WindowIdentifier::GetWindowID() const
68 MOZ_ASSERT(!mIsEmpty);
69 return mWindow ? mWindow->WindowID() : UINT64_MAX;
72 nsPIDOMWindowInner*
73 WindowIdentifier::GetWindow() const
75 MOZ_ASSERT(!mIsEmpty);
76 return mWindow;
79 } // namespace hal
80 } // namespace mozilla