Bug 1688354 [wpt PR 27298] - Treat 'rem' as an absolute unit for font size, a=testonly
[gecko.git] / dom / events / PendingFullscreenEvent.h
blob68cafd3dd165cfb92b990005ddcd8cb97c960393
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 mozilla_PendingFullscreenEvent_h_
8 #define mozilla_PendingFullscreenEvent_h_
10 #include "nsContentUtils.h"
12 namespace mozilla {
14 namespace dom {
15 class Document;
18 enum class FullscreenEventType {
19 Change,
20 Error,
24 * Class for dispatching a fullscreen event. It should be queued and
25 * invoked as part of "run the fullscreen steps" algorithm.
27 class PendingFullscreenEvent {
28 public:
29 PendingFullscreenEvent(FullscreenEventType aType, dom::Document* aDocument,
30 nsINode* aTarget)
31 : mDocument(aDocument), mTarget(aTarget), mType(aType) {
32 MOZ_ASSERT(aDocument);
33 MOZ_ASSERT(aTarget);
36 dom::Document* Document() const { return mDocument; }
38 void Dispatch() {
39 #ifdef DEBUG
40 MOZ_ASSERT(!mDispatched);
41 mDispatched = true;
42 #endif
43 nsString name;
44 switch (mType) {
45 case FullscreenEventType::Change:
46 name = u"fullscreenchange"_ns;
47 break;
48 case FullscreenEventType::Error:
49 name = u"fullscreenerror"_ns;
50 break;
52 nsINode* target = mTarget->GetComposedDoc() == mDocument ? mTarget.get()
53 : mDocument.get();
54 Unused << nsContentUtils::DispatchTrustedEvent(
55 mDocument, target, name, CanBubble::eYes, Cancelable::eNo,
56 Composed::eYes);
59 private:
60 RefPtr<dom::Document> mDocument;
61 nsCOMPtr<nsINode> mTarget;
62 FullscreenEventType mType;
63 #ifdef DEBUG
64 bool mDispatched = false;
65 #endif
68 } // namespace mozilla
70 #endif // mozilla_PendingFullscreenEvent_h_