1 // Copyright 2020 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FULLSCREEN_FULLSCREEN_REQUEST_TYPE_H_
6 #define THIRD_PARTY_BLINK_RENDERER_CORE_FULLSCREEN_FULLSCREEN_REQUEST_TYPE_H_
7 
8 #include "base/check.h"
9 
10 #if DCHECK_IS_ON()
11 #include <string>
12 #endif
13 
14 namespace blink {
15 
16 // This enum class represents Implementation-internal details for the fullscreen
17 // request, these are in addition to API options from fullscreen_options.idl
18 // that are passed separately.
19 //
20 // The integer values are powers of two for use as a flag bitmap. The class
21 // provides minimal operators for combining flags and checking if a specific
22 // flag is set.
23 enum class FullscreenRequestType {
24   // No bits set, equivalent to unprefixed with no other properties
25   kNull = 0,
26 
27   // True for Element.requestFullscreen(), false for
28   // Element.webkitRequestFullscreen()/webkitRequestFullScreen() and
29   // HTMLVideoElement.webkitEnterFullscreen()/webkitEnterFullScreen()
30   kPrefixed = 1,
31 
32   // For WebRemoteFrameImpl to notify that a cross-process descendant frame
33   // has requested and is about to enter fullscreen.
34   kForCrossProcessDescendant = 2,
35 
36   // For WebXR DOM Overlay, in this mode the element and parent iframes use a
37   // transparent background.
38   kForXrOverlay = 4,
39 
40   // Explicit name for "no options" for backwards compatibility and convenience
41   kUnprefixed = kNull,
42 };
43 
44 inline FullscreenRequestType operator|(FullscreenRequestType lhs,
45                                        FullscreenRequestType rhs) {
46   return static_cast<FullscreenRequestType>(static_cast<int>(lhs) |
47                                             static_cast<int>(rhs));
48 }
49 
50 // Returns true if lhs and rhs have at least one flag bit in common.
51 inline bool operator&(FullscreenRequestType lhs, FullscreenRequestType rhs) {
52   return static_cast<int>(lhs) & static_cast<int>(rhs);
53 }
54 
55 #if DCHECK_IS_ON()
56 std::string FullscreenRequestTypeToDebugString(FullscreenRequestType req);
57 #endif
58 
59 }  // namespace blink
60 
61 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_FULLSCREEN_FULLSCREEN_REQUEST_TYPE_H_
62