Bug 1686668 [wpt PR 27185] - Update wpt metadata, a=testonly
[gecko.git] / dom / base / AutoSuppressEventHandlingAndSuspend.h
blob47e80b0521e66661e3c80bb1ef98d1b2699c9d8a
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 #ifndef dom_base_AutoSuppressEventHandlingAndSuspend_h
8 #define dom_base_AutoSuppressEventHandlingAndSuspend_h
10 #include "mozilla/dom/Document.h"
11 #include "nsCOMPtr.h"
12 #include "nsPIDOMWindow.h"
13 #include "nsTArray.h"
15 namespace mozilla::dom {
17 class BrowsingContext;
18 class BrowsingContextGroup;
20 /**
21 * Suppresses event handling and suspends the active inner window for all
22 * in-process documents in a BrowsingContextGroup. This should be used while
23 * spinning the event loop for a synchronous operation (like `window.open()`)
24 * which affects operations in any other window in the same BrowsingContext
25 * group.
28 class MOZ_RAII AutoSuppressEventHandlingAndSuspend {
29 public:
30 explicit AutoSuppressEventHandlingAndSuspend(BrowsingContextGroup* aGroup);
31 ~AutoSuppressEventHandlingAndSuspend();
33 private:
34 void SuppressBrowsingContext(BrowsingContext* aBC);
36 AutoTArray<RefPtr<Document>, 16> mDocuments;
37 AutoTArray<nsCOMPtr<nsPIDOMWindowInner>, 16> mWindows;
39 } // namespace mozilla::dom
41 #endif