Bug 1849470 - Update in-tree zlib to version 1.3. r=aosmond
[gecko.git] / gfx / vr / FxRWindowManager.cpp
blobbecaf214478ffa94f8ec7d2c49d4f51d5c59628e
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "FxRWindowManager.h"
7 #include "mozilla/Assertions.h"
8 #include "nsPIDOMWindow.h"
9 #include "mozilla/ClearOnShutdown.h"
11 #include "nsWindow.h"
13 static mozilla::StaticAutoPtr<FxRWindowManager> sFxrWinMgrInstance;
15 FxRWindowManager* FxRWindowManager::GetInstance() {
16 if (sFxrWinMgrInstance == nullptr) {
17 sFxrWinMgrInstance = new FxRWindowManager();
18 ClearOnShutdown(&sFxrWinMgrInstance);
21 return sFxrWinMgrInstance;
24 FxRWindowManager::FxRWindowManager() : mWindow(nullptr) {}
26 // Track this new Firefox Reality window instance
27 void FxRWindowManager::AddWindow(nsPIDOMWindowOuter* aWindow) {
28 if (mWindow != nullptr) {
29 MOZ_CRASH("Only one window is supported");
32 mWindow = aWindow;
35 // Returns true if the window at the provided ID was created for Firefox Reality
36 bool FxRWindowManager::IsFxRWindow(uint64_t aOuterWindowID) {
37 return (mWindow != nullptr) && (mWindow->WindowID() == aOuterWindowID);
40 // Returns true if the window was created for Firefox Reality
41 bool FxRWindowManager::IsFxRWindow(const nsWindow* aWindow) const {
42 return (mWindow != nullptr) &&
43 (aWindow ==
44 mozilla::widget::WidgetUtils::DOMWindowToWidget(mWindow).take());
47 uint64_t FxRWindowManager::GetWindowID() const {
48 MOZ_ASSERT(mWindow);
49 return mWindow->WindowID();