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/BrowsingContext.h"
11 #include "mozilla/dom/BrowsingContextGroup.h"
12 #include "mozilla/dom/Document.h"
14 #include "nsPIDOMWindow.h"
17 namespace mozilla::dom
{
20 * Suppresses event handling and suspends for all in-process documents in a
21 * BrowsingContext subtree.
23 class MOZ_RAII AutoSuppressEventHandling
: public AutoWalkBrowsingContextGroup
{
25 AutoSuppressEventHandling() = default;
27 explicit AutoSuppressEventHandling(BrowsingContext
* aContext
) {
29 SuppressBrowsingContext(aContext
);
33 ~AutoSuppressEventHandling();
36 virtual void SuppressDocument(Document
* aDocument
) override
;
37 void UnsuppressDocument(Document
* aDocument
) override
;
41 * Suppresses event handling and suspends the active inner window for all
42 * in-process documents in a BrowsingContextGroup. This should be used while
43 * spinning the event loop for a synchronous operation (like `window.open()`)
44 * which affects operations in any other window in the same BrowsingContext
47 class MOZ_RAII AutoSuppressEventHandlingAndSuspend
48 : private AutoSuppressEventHandling
{
50 explicit AutoSuppressEventHandlingAndSuspend(BrowsingContextGroup
* aGroup
) {
52 SuppressBrowsingContextGroup(aGroup
);
56 ~AutoSuppressEventHandlingAndSuspend();
59 void SuppressDocument(Document
* aDocument
) override
;
62 AutoTArray
<nsCOMPtr
<nsPIDOMWindowInner
>, 16> mWindows
;
64 } // namespace mozilla::dom